简体   繁体   中英

How to make an image in a div appear using Javascript

How do I make an image in a div fade in or pop up after aa certain amount of seconds using Javascript? I have researched this but none of the answers on here seem to apply to me.

Thank you

Do you need something like this:

<script>
    setTimeout(function(){document.getElementById('image').style.display = 'block' ? 'none' : 'block'}, 5000)
</script>
<div>
    <div id='image' style='display:none'>
        Here should be your image
    </div>
</div>

You can see it in action here : http://jsfiddle.net/wUb8T/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM