2017-10-12 78 views
0

我有一個字符串,它基本上是這樣的:jQuery的解析統一characthers

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 

凡"應表示爲:「characther ...

在我的JS方法中,我將標籤值設置爲以下內容:

function WriteTitle(sentTitle){ 
$("#myTitle").text(sentTitle); 
} 

我一直在使用像decodeURIComponent,UNESCAPE或類似的方法來分析這些characthers嘗試,但至今沒有運氣...

我如何分析這些進入正常角色?

+0

這可能是一個重複:https://stackoverflow.com/questions/7885096/how-do-i-decode-a-string-with-escaped-unicode – Nick

回答

1

這些不是unicode字符,而是HTML entities。你應該使用.html()方法,它不會逃脫它們(這正是.text()所做的)。

function WriteTitle(sentTitle){ 
    $("#myTitle").html(sentTitle); 
} 
+0

耶這是它!太多了! – User987

+0

@ User987不客氣。不要忘記接受我的答案。 – Styx