Reputation: 55
I am using jquerymbiles 1.4.2.I want my image to be display for a 5 seconds when we click on a div. The code which i am using in my page is here click
<script>
$(document).ready(function () {
$(".hr").click(function(){
$("#imgstate").show();
});
});
</script>
The above code displays the image when we click n a div but i dm not getting how to hide it after a 5 seconds please help me in this
Upvotes: 0
Views: 54
Reputation: 38102
You can use .delay():
$(document).ready(function () {
$(".hr").click(function () {
$("#imgstate").show().delay(5000).hide();
});
});
Try to use .setTimeout()
here:
$(document).ready(function () {
$(".hr").click(function () {
$("#imgstate").show();
setTimeout(function() {
$("#imgstate").hide();
}, 5000);
});
});
Upvotes: 1