Try this code
JS
$(".pop").on('click', function() {
// Get the closest anchor container
var $a =$(this).closest('a');
// Insert after the last anchor container
$a.insertAfter('a:last')
})
Also bind
has been superseeded by on
. Use that to bind event handlers.
Also your html can be cleaned up a bit, by not repeating the same styles. Move the common styles to the same class.
CSS
.pop{
width: 100px;
height: 100px;
position: relative;
}
#pop0 {
background: yellow;
}
#pop1 {
background: red;
}
#pop2 {
background: blue;
}
#pop3 {
background: green;
}
Check Fiddle
2
solved remove Div and appear it another place [duplicate]