Reputation: 287
Good morning.
I'm having a doubt. Anyone know to do to move a div down or up?...
My example code. Over the div I want to pass up and 3 before the div click, then will be up 4 div. Anyone know how I can make the selection of this div
$(".up").click(function(){
$(this).parent().prev().prev().prev().insertBefore($(this).parent().prev())
});
HTML
<div class="1" >
<div class="2">
<div class="3">
<div class="4">
<div class="up">UP</div>
</div>
</div>
</div>
</div>
<div class="1" >
<div class="2">
<div class="3">
<div class="4">
<div class="up">UP</div>
</div>
</div>
</div>
</div>
I would be very grateful for the help.
Upvotes: 0
Views: 909
Reputation: 15867
$(".up").click(function() {
$(this).parents(".1").insertBefore($(this).parents(".1").prev(".1"));
});
Upvotes: 3