jQuery.不是吗? [英] jQuery .nothas?
本文介绍了jQuery.不是吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有一种方法可以等效于jQuery中的.nothas()
选择器?例如,如果我想向所有尚没有元素的TABLE
元素添加TBODY
,那么做这样的事情会很好:
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 />");
如果将其限制为直接后代,那就更好了,这样(在这种情况下)将不会考虑嵌入在THEAD
单元格中的TABLE
元素.
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 />");
这篇关于jQuery.不是吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文