使用 javascript 函数将一个 unicode 转换为另一个 unicode



目标:单击时将箭头更改为向下。

我尝试在 Javascript 中使用不同的 unicode 来更改它,但即使通过"\"转义,我也只是获得基本字符串......

几乎没有失去。希望这是一个简单的问题。

$('.col-exp').on('click', function() {
  let th = $(this);
  th.children('span').text('***Change to down arrow***');
  th.next('section').slideToggle();
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<h2 class="col-exp">Employment<span>&#11206;</span></h2>
<section id="employment">
  <table>
    <tr>
      <td>FakeSystems Inc</td>
      <td>Master Developer</td>
      <td>2000-2010</td>
      <td>Managed API routing by coordinating with foo and assessing the accuracy of returned data from 3rd party partners</td>
    </tr>
    <tr>
      <td>WorseSystems Inc</td>
      <td>Lesser Developer</td>
      <td>1990-2000</td>
      <td>Made sites with Geocities and Angelfire that included tons of <code>blink</code> tags and gifs to make me look awesome</td>
    </tr>
  </table>
</section>
<h2 class="col-exp">Education<span>&#11206;</span></h2>
<section id="education">
  <table>
    <tr>
      <td>Fake Institute of Fortitude</td>
      <td>1986-1990</td>
    </tr>
  </table>
</section>
</div>
</div>

您需要

使用.html,因为它是HTML实体之一。

使用 .text ,它将被当作纯文本,不会被解析为 HTML。

$('.col-exp').on('click', function(){
  let th = $(this);
  th.children('span').html('&#11205;');
  th.next('section').slideToggle();
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<h2 class="col-exp">Employment<span>&#11206;</span></h2>
<section id="employment">
  <table>
    <tr>
      <td>FakeSystems Inc</td>
      <td>Master Developer</td>
      <td>2000-2010</td>
      <td>Managed API routing by coordinating with foo and assessing the accuracy of returned data from 3rd party partners</td>
    </tr>
    <tr>
      <td>WorseSystems Inc</td>
      <td>Lesser Developer</td>
      <td>1990-2000</td>
      <td>Made sites with Geocities and Angelfire that included tons of <code>blink</code> tags and gifs to make me look awesome</td>
    </tr>
  </table>
</section>
<h2 class="col-exp">Education<span>&#11206;</span></h2>
<section id="education">
  <table>
    <tr>
      <td>Fake Institute of Fortitude</td>
      <td>1986-1990</td>
    </tr>
  </table>
</section>

相关内容

最新更新