javascript - Jquery: Add class unless there is a child of certain class -
I want to advertise one, but only if there is no child of a particular class.
$ selector.addClass ('addthisclass');
So I want to:
& lt; Div class = "addthisclass" & gt; & Lt; Span & gt; & Lt; / Span & gt; & Lt; / Div & gt;
And nothing here.
& lt; Div & gt; & Lt; Span class = "badclass" & gt; & Lt; / Span & gt; & Lt; / Div & gt;
How does anyone know this?
Selector:
$ ("div: not (: (Span.badclass)) ". AddClass ("addthisclass");
Comments
Post a Comment