vendredi 15 juillet 2016

Add class if child element not present


If this works when a class is present...

$('.priority').children('.no-priority').addClass('normal');

How would I add a class if the child class .no-priority is missing?

Tried code below which does not work

if (!$('.priority').children('.no-priority')) {
 $('.priority').addClass('prioritised');
 }

Neither does

$('.priority').not('.no-priority').addClass('prioritised');

Aucun commentaire:

Enregistrer un commentaire