jQuery .nothas?

jquery, jquery-selectors

Solution

jQuery has `:not` and `:has` selectors:

$("table:not(:has(tbody))").append("<tbody />");

Problem

Is there a way to do the equivalent of a `.nothas()` selector in jQuery? For example, if I wanted to add a `TBODY` to all `TABLE` elements that didn't already have one, it would be nice to do something like this: ``` $("TABLE").nothas("TBODY").append("<TBODY />"); ``` It would be even better if this could be limited to direct descendents, so that (in this case) `TABLE` elements embedded in `THEAD` cells wouldn't be considered.

Original source