Matching jquery .text() to  

前端 未结 2 1328
不思量自难忘°
不思量自难忘° 2021-02-07 08:34

Due to circumstances out of my control, SharePoint, I have the following piece of code.

var item = $(\' <         


        
相关标签:
2条回答
  • 2021-02-07 09:20

    Compare it to &nbsp;, as that is the content you want to match. It appears not to be that because the browser renders is as space, rather than characters. Comparing it to &nbsp; should result in either two sets of &nbsp;s being compared, or two identical spaces being compared.

    0 讨论(0)
  • 2021-02-07 09:30

    Try checking for '\xa0' (which is the character created by &nbsp;):

    var item = $("<span><font size=1>&nbsp;</font></span>").text();
    alert("'" + item + "' " + (item == '\xa0'));
    

    http://jsfiddle.net/hUBeP/3/

    0 讨论(0)
提交回复
热议问题