[英]Target element with 2 classes inside a jquery not selector
我似乎無法使它正常工作,這可能很簡單,但是我們開始:
這是我的選擇器,我想查找同時具有selection [0]和selection [1]類的元素,但這並不查找同時具有這兩個元素的元素。 據我所知,它只會抓住第一個選擇類並進行查找。
$(this).not("." + selection[0], "." + selection[1]).hide();
我試過像這樣手動輸入,它可以正常工作:
$(this).not(".class1.class2").hide();
我猜逗號用逗號分隔選擇器,並且在那里出錯。 但是,如何實現相同的功能?
用+
代替逗號,
以將dot [0]連接起來.
$(this).not("." + selection[0] + "." + selection[1]).hide();
這條線
$(this).not("." + selection[0], "." + selection[1]).hide();
具有語法錯誤(不是從JS的角度來看,而是從jquery選擇器的角度來看)
做了
$(this).not("." + selection[0] + "." + selection[1]).hide(); //replaced comma with +
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.