Due to circumstances out of my control, SharePoint, I have the following piece of code.
var item = $('<span><font size=1> </font></span>').text()
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?
EDIT: Example fiddle
http://jsfiddle.net/hUBeP/2/
Try checking for '\xa0'
(which is the character created by
):
var item = $("<span><font size=1> </font></span>").text();
alert("'" + item + "' " + (item == '\xa0'));
http://jsfiddle.net/hUBeP/3/
Compare it to
, 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
should result in either two sets of
s being compared, or two identical spaces being compared.