Reuben
Reuben

Reputation: 2751

if div has class remove the class and add it to its parent

I have

<div class="image-mask">
    <img class="alignright" src="image.png" />
</div>

and I would like to use jQuery to move the class from the image to the parent div.

Thanks very much!!

Upvotes: 0

Views: 714

Answers (1)

Sam Dolan
Sam Dolan

Reputation: 32532

This should work:

 $('.alignright').removeClass('alignright').parent().addClass('alignright');

Upvotes: 5

Related Questions