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

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

    You have wrong syntax in using the logical or || operator

    Change

     if ($(this).val() == "Spine"||"Brain") {
    

    To

    if ($(this).val() == "Spine"|| $(this).val() == "Brain") {
    

    You can use value with javascript object instead of val() of jquery object, as Fabrício Matté suggested. It would give you performance benefit.

    if (this.value == "Spine" || this.value == "Brain")
    

提交回复
热议问题