[英]how to use unicode character in javascript
For a js click function to View and Hide some comments, i use this unicode ▼
对于 js 点击 function 查看和隐藏一些评论,我使用这个 unicode
▼
and ▲
和
▲
(Arrow up and arrow down) (向上箭头和向下箭头)
$('.toggle-<?php echo $comment_id; ?>').click(function(){
$(this).text($(this).text() == 'Hide replies ▲' ? 'View replies ▼' : 'Hide replies ▲');
But it shows me literally the code instead of the arrow.但它从字面上向我显示了代码而不是箭头。
So how i need to use the code in the script above?那么我需要如何使用上面脚本中的代码呢?
The syntax &#<num>;
语法
&#<num>;
is html, therefore it needs to be entered as such, using $(...).html('▼...')
instead of $(...).text('▼...')
.是 html,因此需要这样输入,使用
$(...).html('▼...')
而不是$(...).text('▼...')
.
The following should work:以下应该有效:
$(this).html($(this).text().substr(0,4) == 'Hide' ? 'View replies ▼' : 'Hide replies ▲');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.