我可以使用以下代码成功隐藏 id 中包含字符串的 div:
按钮:
<input type="button" id="mytest" value="filter"></input>
js代码:
//hides divs with class=screen3 and with 99 in its id
$('#myteste').click (function () {
$('div.screen3[id*="99"]').hide();
});
现在我需要做相反的事情,隐藏 id 中不包含字符串的 div,但我不知道如何操作。
最佳答案
你可以这样做:
$('div.screen3').not('[id~="99"]').hide(); // tests the word (delimited by spaces)
或
$('div.screen3').not('[id*="99"]').hide(); // tests the string
关于jquery - 根据 div 的 id 过滤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14568750/