if($("#target").html().trim().length>0){do sth}
it is weird i got the error says Uncaught TypeError: Cannot read property ‘length’ of undefined
and in the html i have
<div id="target"><table><tr><td>ABC</td></tr></table></div>
And the weird issue is if i do the console.info($("#target").html().trim().length), it will tell me some number.
and the most weird thing i found the only way to avoid that error is change the html content
<div id="target">ABC</div>
without the html table, it will do not throw that errow
try to use innerHTML or innerText directly instead of Jquery