.after () puts the first div as the last

Grab everything, I have a basic big jQuery. What I'm trying to do is take the first div from the group div and make it the last div in the group, the HTML looks like this:

<div>
    <div id=1></div>
    <div id=2></div>
    <div id=3></div>
    <div id=4></div>
</div>

I use

$("div div:first").after( $("div div:last") );

However, it does not work.

any ideas?

+3
source share
2 answers

You have your items back. The first selector needs to select the element you want to insert, and the second selector accepts the element you want to insert:

$('div div:last').after($('div div:first'));
+2
source

jQuery . div div. , jQuery ( div)

$('.someClass div:first').appendTo($('.someClass'));
0

Source: https://habr.com/ru/post/1773651/


All Articles