开发者

Jquery, hide img onload

开发者 https://www.devze.com 2023-03-11 17:32 出处:网络
I want an image to be hidden when page just loaded. I can call $(\'#imgName\').show() to show the image.

I want an image to be hidden when page just loaded. I can call $('#imgName').show() to show the image.

However, I had

$(document).ready(function() {
    $("#imgName").hide();
});开发者_如何学JAVA

But the image still flashes right at the start.

How do you get rid of this flashing effect?


Use CSS 'display: none;' to make it not visible on load.


This is because javascripts are loaded after html, the nearest possible solution is to use css

img#imgName{display:none}


Try using CSS to initially hide the image. The Javascript will load after the CSS, generally -- ergo, the initial flash.


You can load the image with it hidden using css.

display:none;
0

精彩评论

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