Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用jQuery通过缺少属性查找子元素_Javascript_Jquery_Html - Fatal编程技术网

Javascript 使用jQuery通过缺少属性查找子元素

Javascript 使用jQuery通过缺少属性查找子元素,javascript,jquery,html,Javascript,Jquery,Html,在jQuery中按属性查找元素很简单: $(parentElement).find('[attribute]'); 如何找到不具有特定属性的元素?这就是为什么要为 试试看 您可以使用:not,尽管过滤器很可能更快: $(parentElement).filter(function() { return !$(this).attr('attribute'); }); 或者,$(parentElement).find('[attribute]')。not([attribute]);拉贾普

在jQuery中按属性查找元素很简单:

$(parentElement).find('[attribute]');
如何找到不具有特定属性的元素?

这就是为什么要为

试试看


您可以使用
:not
,尽管
过滤器很可能更快:

$(parentElement).filter(function() {
    return !$(this).attr('attribute');
});

或者,$(parentElement).find('[attribute]')。not([attribute]);拉贾普拉布胡是对的。看小提琴。Active-Inactive$('div:not([target=“_blank”])).css('font-weight','bold');
$(parentElement).filter(function() {
    return !$(this).attr('attribute');
});