I have several divs with unique class 'slide_image', and unique id. Inside each divs I have 2 a links, "#next" and "#prev". what I'm trying to do is to get for each divs the id of the next and prev divs, and attribute the id ty links.
for example for .slide_image id=slide_3
<div id="slide_2" class="slide_image">
1
<a href="#slide_3" id="next"></a><a href="#slide_1" id="prev"></a>
</div>
<div id="slide_3" class="slide_image">
1
<a href="#slide_4" id="next"></a><a href="#slide_2" id="prev"></a>
</div>
here is what I've tried but its not working, I think I have a problem with my each() functions :
$('.slide_image').each(function(e){
var next_link = $(this).next().attr('id');
$( "a#next" ).next().attr("href", next_link)
});
$('.slide_image').each(function(e){
var prev_link = $(this).prev().attr('id');
$( "a#prev" ).prev().attr("href", prev_link)
});
here is a Jsfiddle with all my code : http://jsfiddle.net/4yzg25o2/1/
can anybody help me with this ?
thanks a lot,