我试图按照以下方式做 选择父类“search-result-item”,并跳过其中的h3标签和选择的btn-grey类。我的代码是在这里jquery不选择不工作
$('div.search-result-item:not(h3 .btn-grey)').click(function(e){
console.log('1');
});
但它选择h3和btn-gray也是我做错了什么?
我试图按照以下方式做 选择父类“search-result-item”,并跳过其中的h3标签和选择的btn-grey类。我的代码是在这里jquery不选择不工作
$('div.search-result-item:not(h3 .btn-grey)').click(function(e){
console.log('1');
});
但它选择h3和btn-gray也是我做错了什么?
尝试,
或更好的解决方案为狼建议,
$('div.search-result-item :not("h3,.btn-grey")')
':不是(h3,.btn-grey)' –
我不确定OP在找什么,想排除两者还是什么?! (当然,我没有downvoted你的答案) –
@ A.Wolff是啊操作正试图排除这两个.. –
试试这样:
$('div.search-result-item').not('h3 .btn-grey').click(function(e){
console.log('1');
});
您可能需要采取“一看:有( )“选择器,http://api.jquery.com/has-selector/。
$("div.search-result-item:not(:has(h3.btn-grey)")
你能为它创建一个小提琴吗? – Guilherme
发布适用于您的问题的HTML。你的'h3'里面的'.btn-grey'是否为 – j08691
?或者他们是同一个元素? – Skwal