页面完全加载后如何显示图像?

时间:2014-10-18 22:51:25

标签: javascript jquery html

我的图片需要在页面完全加载后显示下面是代码示例任何帮助将不胜感激

<div id="playbutton">
<img style="width: 200px; height: 200px; border: 0;" src="http://iconshots.com/wp-content/uploads/2010/01/final1.jpg">

</div>

2 个答案:

答案 0 :(得分:2)

隐藏图片开头;具有此规则的style="display:none;css类很好。然后等待 DOM和所有图形(图像)加载,然后显示图像:

<强> HTML

<div id="playbutton">
<img style="width: 200px; height: 200px; border: 0;display:none;" src="http://iconshots.com/wp-content/uploads/2010/01/final1.jpg">

</div>

<强> JS

$(window).load(function() {
  $('#playbutton img').show();
});

答案 1 :(得分:0)

您可以将其display属性设置为none

<img id='hiddenImage' style="display:none; width: 200px; height: 200px; border: 0;" src="http://iconshots.com/wp-content/uploads/2010/01/final1.jpg">

并在加载页面时使用jquery更改它

$(document).ready(function(){
    $('#hiddenImage').show();
});