Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using .next() to find a div and .append() to append back to the first?

I set up a simple JSfiddle..

http://jsfiddle.net/DbetR/

$("div.postdata").next(".content").appendTo(".postdata");

this is probably not working because it's trying to append it's self to it's self or something. Any ideas on how to go about this?

I want content 1 to append to the first div, and content 2 to the second.

Thanks!

like image 980
Austin R Kowitz Avatar asked Jan 25 '26 00:01

Austin R Kowitz


1 Answers

Next sibling of each .postdata is <p> element, and not .content. You can use something like that to make the things workable:

$("div.postdata").each(function() {
    $(this).nextAll(".content:first").appendTo(this);
});

DEMO: http://jsfiddle.net/DbetR/2/

like image 91
VisioN Avatar answered Jan 26 '26 13:01

VisioN