Reputation:
I have 5 divs with the following ID's;
- slide0
- slide1
- slide2
- slide3
- slide4
I'd like to select them using a variable and id.
var clk = 0;
The clk is incremented each time the function is ran.
$('slide' + clk).fadeOut()
<-- How do I make this work?
I'm new to jQuery and in javascript it would have been as simple as;
document.getElementById('slide' + clk).style
Upvotes: 0
Views: 110
Reputation: 336
$(document).ready(function () {
var clk = 0;
for (var i = 0; i < 5; i++) {
$('#slide' + clk).fadeOut();
}
});
Upvotes: 0