jQuery - Moving a div to the top of it's parent
jquery
Solution
`$('this')` selects `<this></this>` elements.
I would do something like this:
$(".pane-bundle-hblock .field-name-field-hblock-image-right").each(function() {
$(this).parent().prepend(this);
});
If the element doesn't exist, the `.each()` won't have anything to iterate over, so you don't really need to check to see if it exists.
Problem
I've got a script where if a div exists I want to be at the top of it's parent div. Here's what I tried: ``` if ($(".pane-bundle-hblock .field-name-field-hblock-image-right").length){ $(".pane-bundle-hblock .field-name-field-hblock-image-right").parent().prepend($('this')); } ``` What did I get wrong?