本文介绍了将jquery .text()匹配到& nbsp;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
由于SharePoint无法控制的情况,我有以下代码.
Due to circumstances out of my control, SharePoint, I have the following piece of code.
var item = $('<span><font size=1> </font></span>').text()
我正在尝试将.text()
值与
进行比较,但不知道该怎么办.单步执行代码item
似乎等于",这很有意义.但是执行item == " "
会返回false.应该如何进行比较?
I am trying to compare the .text()
value to
and don't know what to do. Stepping through the code item
seems to equal " " which makes sense. But doing item == " "
returns false. How should this comparison be done?
小提琴示例
推荐答案
尝试检查'\xa0'
(这是
创建的字符):
Try checking for '\xa0'
(which is the character created by
):
var item = $("<span><font size=1> </font></span>").text();
alert("'" + item + "' " + (item == '\xa0'));
这篇关于将jquery .text()匹配到& nbsp;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!