我有一个基本上如下所示的字符串:
20 pcs 1/4" d 13/32" l shank copper round head solid rivets fasteners
或:
20 Pcs 1/4" D 13/32" L Shank Copper Round Head Solid Rivets Fasteners
其中“应表示为:”字符...
在我的 JS 方法中,我将标签值设置为以下:
function WriteTitle(sentTitle){
$("#myTitle").text(sentTitle);
}
我尝试过使用decodeURIComponent、unescape或类似的方法来解析这些字符,但到目前为止没有运气......
如何将这些解析为普通字符?
最佳答案
这些不是 unicode 字符,而是 HTML entities 。您应该使用 .html()
方法,它不会转义它们(这正是 .text()
所做的)。
function WriteTitle(sentTitle){
$("#myTitle").html(sentTitle);
}
关于javascript - jQuery 解析字符串中的 unicode 字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46715922/