2014-04-09 267 views
-1

我試圖按照以下方式做 選擇父類「search-result-item」,並跳過其中的h3標籤和選擇的btn-grey類。我的代碼是在這裏jquery不選擇不工作

$('div.search-result-item:not(h3 .btn-grey)').click(function(e){ 
    console.log('1'); 
}); 

但它選擇h3和btn-gray也是我做錯了什麼?

+1

你能爲它創建一個小提琴嗎? – Guilherme

+2

發佈適用於您的問題的HTML。你的'h3'裏面的'.btn-grey'是否爲 – j08691

+0

?或者他們是同一個元素? – Skwal

回答

2

嘗試,

​​

或更好的解決方案爲狼建議,

$('div.search-result-item :not("h3,.btn-grey")') 
+3

':不是(h3,.btn-grey)' –

+0

我不確定OP在找什麼,想排除兩者還是什麼?! (當然,我沒有downvoted你的答案) –

+0

@ A.Wolff是啊操作正試圖排除這兩個.. –

0

試試這樣:

$('div.search-result-item').not('h3 .btn-grey').click(function(e){ 
    console.log('1'); 
});