开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜