Can't make multiple if conditions in JavaScript?

前端 未结 6 580
一整个雨季
一整个雨季 2021-01-28 23:15

I have absolutely no idea why this is not working. Makes no sense to me.

This returns a \"syntax error: parse error\":

if ($(this).attr(\"id\") === \'se         


        
6条回答
  •  说谎
    说谎 (楼主)
    2021-01-28 23:42

    When you test like this:

    opening=true;
    

    What you are really doing is setting opening to the value of true. Use == instead.

    Finally, order of operations, even if correct, can get confusing. Put parenthesis around each part of the comparison.

    if (($(this).attr("id") === 'search') || (opening == true)) return false;
    

提交回复
热议问题