I am trying to use jquery each() function but i think there is something wrong.
Here is the html and jquery code.
<div class="tribute">
<div class="image"></div>
<div class="links"></div>
</div>
<div class="tribute odd">
<div class="image"></div>
<div class="links"></div>
</div>
<div class="tribute">
<div class="image"></div>
<div class="links"></div>
</div>
<div class="tribute odd">
<div class="image"></div>
<div class="links"></div>
</div>
<div class="tribute">
<div class="image"></div>
<div class="links"></div>
</div>
<div class="tribute odd">
<div class="image"></div>
<div class="links"></div>
</div>
and jquery function
jQuery('.odd').each(function(index, value){
var oddLinks = jQuery('.odd').find('.links').detach();
jQuery('.odd .image').before(oddLinks);
});
this code is not properly working for me.
.each()method runs a loop through the matched elements, in this case it is all the<div>s with.odd. I don't see you usingindexorvalue,valuerefers to the singular matched element. Why are you doing$('.odd')again inside the.each()loop?