[ACCEPTED]-How to appendTo closest div (by class)?-closest
Accepted answer
You need to loop through using .each()
so this
refers 3 to each element as you go, like this:
$(".newsImage").each(function() {
$(this).closest(".newsItem").append(this);
});
Since 2 .appendTo()
gets flipped around to .append()
anyway, it's more 1 efficient to go this route.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.