Can't make multiple if conditions in JavaScript?

前端 未结 6 578
一整个雨季
一整个雨季 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:27

    You have an error in your condition

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

    should be

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

    the problem is with the equals sign

    = is different to ==

    the first one is the assignment operator. the second one is for comparison

提交回复
热议问题