How would I add a class to a figure element if an image inside it has a class of right?, I only want this to execute if a image has a class of right.
$(function() {
if ($('img').hasClass('right')) {
$('figure').addClass('test');
}
});
This adds a class test to every figure on the page?
Aucun commentaire:
Enregistrer un commentaire