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

后端 未结 6 956
北海茫月
北海茫月 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:41

    I would use a different approach. Especially if the list grows. If you get a list that has several parts, the conditional gets ugly.

    var parts = ["Spine", "Brain"];
    var value = $(this).val();
    
    if($.inArray(value, parts) > -1){
        //do something    
    }
    

提交回复
热议问题