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

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -