Skip to content
Advertisement

Insert each div inside next div (jQuery)

How can I insert div.one into his next div.two with jquery?

What it is:

JavaScript

What I want:

JavaScript

What I tried (but it insert all div.one in every div.two):

JavaScript

Whats my fail?

Advertisement

Answer

You were close:

JavaScript

using the class in the preprendTo() function will of course select all the .box.two elements, instead by doing $(this).next() we only get the very next sibling element.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement