div is null in ie but in mozila and opera
<div id="a"></div>
if($("#a").is(':empty') )
alert("empty"开发者_JAVA技巧);
In IE8, it shows alert
but Mozila 3.6 and Opera 11 do not show the alert
. Why?
Answer:
if(!$.trim( $("#a").html() ) )
alert("empty");
this code run in ie and mozila
Your code is valid and should work in those browsers. I tested it in FireFox and Chrome and it works.
Verify that you do not have any other elements in your page that also have an id of a
. Most browsers compliant with web standards correctly refuse to acknowledge any duplicated elements and often it causes JavaScripts to fail due to errors.
精彩评论