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.
jQuery has :not and :has selectors:
$("table:not(:has(tbody))").append("<tbody />");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With