This code is working fine if ($(this).val() == “Spine”) but not ($(this).val() == “Spine”||“Brian”)

后端 未结 6 954
北海茫月
北海茫月 2021-01-20 04:28

This code is working fine if ($(this).val() == \"Spine\") but if ($(this).val() == \"Spine\"||\"Brian\") then the selection menu closes then opens

6条回答
  •  别那么骄傲
    2021-01-20 04:57

    or use switch case

    $("#optionbodyRegion").change(function(){
        switch ($(this).val())
    {
       case "Spine": case "Brain": 
        document.getElementById('optioncontrast').options[0]=new Option("Select", "", false, false)
                        document.getElementById('optioncontrast').options[1]=new Option("With", "With", false, false)
                        document.getElementById('optioncontrast').options[2]=new Option("Without", "Without", false, false)
                        document.getElementById('optioncontrast').options[3]=new Option("With and Without", "With and Without", false, false)
    
    
                        $("#contrast").slideDown("fast"); //Slide Down Effect
       break;
     case "":
    $("#contrast").slideUp("fast");   //Slide Up Effect
    break;
    
      default: 
      break;
    }
    

提交回复
热议问题