除非在此之后调用警报,否则jquery show()不起作用

时间:2014-07-12 03:54:40

标签: javascript jquery html css

我使用jquery.show()来显示div,但我无法看到显示效果,除非在show方法之后调用警告:

JavaScript的:

 $("#screenAsLayer").show();
 $("#screenAsLayer_content").show();
 alert("aa");

HTML:

<div id="screenAsLayer" class="screenAsLayer"></div>
<div id="screenAsLayer_content" class="screenAsLayer_content">
  <img src="..../img/....gif">
</div>

CSS:

.screenAsLayer{
 display:none;
 z-index:9;
 position:abosolute;
}
.screenAsLayer_content{
 display:none;
 z-index:10;
 position:abosolute;
}

JSFiddle Demo

1 个答案:

答案 0 :(得分:2)

试一试:

$(document).ready(function() {
 $("#screenAsLayer").show();
 $("#screenAsLayer_content").show();
});

Working Fiddle