简体   繁体   中英

Display image on click in HTML / Javascript

hey, how can I make an image visible when a user clicks a button? Using Html / Javascript

Also, the button is submitting a form which is going to a different url, it just takes a while to load the other page, therfore I want a loading type button.

Thanks

It's simple to acheive this across all modern browsers using jQuery:

<input type="submit" value="Show Image" id="showButton" />
<img src="blank.gif" id="blankImage" alt="blank" style="display: none;" />

<script type="text/javascript">
$('#showButton').click( function() {
    $('#blankImage').show();
    return false;
});
</script>

将图像的visible属性设置为true?

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