简体   繁体   English

使用fliter.js的多个ID选择器

[英]multiple id selector using fliter.js

Now i have two divs with different id ( #filter1 , #filter2 ). 现在我有两个具有不同ID的div( #filter1#filter2 )。 I want the selection inside div ( .tags ) can change the result of ( #filter1 , #filter2 ) at the same time. 我希望div( .tags )内的选择可以同时更改( #filter1#filter2 )的结果。

I have tried to use multiple id selector, but seems cannot work. 我尝试使用多个ID选择器,但似乎无法正常工作。

$(function(){
$('#filter1, #filter2').filter();
});

additionally, i would like to set while i selected D1, the multiple selection of D2 will be disabled it can just switch the option from D1 to D2 if i click D2 (as they are in the same catagory) 另外,我想在选择D1时进行设置,但D2的多重选择将被禁用,如果我单击D2,则可以将选项从D1切换到D2(因为它们在同一类别中)

DEMO DEMO

i am a beginner on js, hope can get help from you 我是js的初学者,希望可以从您那里获得帮助

many thanks 非常感谢

You can achieve this by using "each()". 您可以使用“ each()”来实现。 See following script: 请参阅以下脚本:

$("#filter1,#filter2").each(function(){
    $(this).filter();
});

So to disable using multiple selectors, you can get it by this: 因此,要禁用多个选择器,可以通过以下方式获取它:

$("#filter1,#filter2").each(function(){
    $(this).attr('disabled','disabled');
});

Select the check if it is useful to you ;) 选择检查是否对您有用;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM