Reputation: 167
Situation:
I create small information divs in the corner of the page. Those are generated by messages I set. The information are placed above each other. The divs have a class = "informatiemelding"
.
To accomplish:
Is there a way to add a fade timer for each div that has the class name "informatiemelding", so that no matter how many information divs are on screen they will all disappear a number of seconds. I have jQuery. I tried:
<script type="text/javascript">
jQuery(".informatiemelding").setTimeout(function () {
$(this).fadeOut('slow');
});
</script>
But that just gave me a error that "Uncaught TypeError: Object [object Object] has no method 'setTimeout'". So I'm grabbing the divs in the wrong way I suppose.
Since I'm a utter noob with jQuery can somebody explain me what to do? Javascript isn't something that I understand. Getting better at it but I'm more in to PHP :P
Upvotes: 3
Views: 6381
Reputation: 1723
setTimeout(function () {
$(".informatiemelding").fadeOut('slow');
}, 1000 /* Time to wait in milliseconds */);
Upvotes: 4