简体   繁体   中英

show/hide div on select change

I'm trying to show/hide a div element on select change depending on values which is working fine but problem is i am using multiple select box on single page and on change all values show hide at same time . For that I do this:

    jQuery(function() {
  jQuery('.selector').change(function(){
    jQuery('.inv').hide();
    jQuery('.' + $(this).val()).show();
  });
});

如果您在屏幕截图中看到我有 3 个选项 vps-1、vps-2、vps-3 点击选择我只想更改该框的值

What I'm doing wrong? please help

try jQuery('.selector').closest( ".inv" ).hide(); as jQuery('.inv').hide(); will find everything with that class on it and hide it hence whats happening

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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