Can someone please explain this to me? I am attempting to do something if key != ''
var key = "";
if($('div[title="Keyword"]').text() != '') {
key = $('div[title="Keyword"]').text().trim();
}
//this always alerts
if (key != '') { alert(key); }
//this never alerts
if (!key) { alert(key); }
I said in the comments it might be an invisible character not stripped by
trim. Well, after your further comments, it’s clear that’s the case. It’s the U+200B Zero-width space character. It probably came from jsfiddle (I’m betting you pasted something from there).