tags:

views:

58

answers:

1

Considering the code:

<noscript><div>FOO</div></noscript>

Running

$('noscript').html();

returns &lt;div&gt;FOO&lt;/div&gt;

but running

$('noscript').text();

returns the raw html.

This is the opposite of what I was expecting. Is there an explanation for this?

+2  A: 

This more of a DOM quirk than a jQuery quirk:

$("<noscript><div>FOO</div></noscript>")[0].innerHTML == "&lt;div&gt;FOO&lt;/div&gt;"

$("<noscript><div>FOO</div></noscript>")[0].textContent == "<div>FOO</div>"

Basically, behavior for this action isn't consistent, as this answer explains.

Jed Schmidt