JSFiddle: http://jsfiddle.net/QbyUR/
So, I have an empty TD, that I’m trying to remove the white space from.
Normally I’d do this:
ee.replace(/\s+/, '') == "" // check to see if TD is empty.
the above returns false
but, it wasn’t working so I pasted the contents of my TD to a unicode decoder and got this:
U+000D <control> character
U+000A <control> character
U+0009 <control> character
U+0009 <control> character
U+0009 <control> character
U+0009 <control> character
U+0020 SPACE character
or

				 
The text that I converted is here:
-------
-------
(in between the two lines)
this is what I used: http://software.hixie.ch/utilities/cgi/unicode-decoder/utf8-decoder
I’m 100% certain it’s the control characters that are messing me up. And they are bound to be different across all browsers…
How do I get rid of them? is a regex replace going to be sufficient?
The real problem here is that you’re using
innerText, which is not a property on jQuery objects but rather on DOM elements. Simply use the jQuery function.text()instead:And everything will work fine. Right now, the string is actually
"undefined"because you appended an empty string to a nonexistent property.