I am trying to iterate over every div with the the id ‘slide’ and add a number to the end (e.g slide1, slide2, etc)
I have been able to have a series of classes added to each div, but I can only get the same code to rename the first slide, not the rest of them.
$(document).ready(function() {
$("#slide").each(function(i) {
$(this).attr('id', "slide" + (i + 1));
});
});
and jsfiddle here http://jsfiddle.net/YsvCe/1/
Thanks in advance
You should use classes rather than ids for multiple elements.
Example: http://jsfiddle.net/QaB76/