简体   繁体   中英

Dropdown logic using javascript

I have three dropdowns in my html page using bootstrap,i want to display the content of second dropdown in relation to first one.

Supposedly an option 3 is chosen from five options in dropdown 1 it should not be visible in dropdown 2 and so on.

Bind the change event of the first dropDown to a function responsible of dynamically change the content of the second drop down. For more explanation you have to post the code.

This piece of code will remove options with the same name as in your example. I'd use a switch for all variations.

$(".dropdown-menu li a").click(function(){
  var option = $(this).text();
  $(".dropdown-menu li a:contains('"+option+"')").css("display","none");
  //remember to handle what should be visible as well
});

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