Your code (I fixed the closing parenthesis):
".PhotoLine:eq(" + IndexValue + 1 + ")";
will concatenate as a string. If IndexValue
equals 3, then you'll get the string .PhotoLine:eq(31)
instead of .PhotoLine:eq(4)
. What you meant was:
".PhotoLine:eq(" + (IndexValue + 1) + ")";
But even then it won't work quite right.
For simplicity, you can avoid using eq
at all by instead selecting .next('.PhotoLine')
(or just .next()
, but I like to be accurate to avoid unexpected surprises):
$('.PriceAndButton').each(function(i,el) {
$(this).insertAfter($(this).next('.PhotoLine'));
});