jQuery Window Width else if statement

后端 未结 3 1883
天涯浪人
天涯浪人 2021-02-04 21:16

I am wondering why my last else if statement never gets executed. I am trying to do this:

$(document).ready(function() {
    function checkWidth() {
        var          


        
3条回答
  •  礼貌的吻别
    2021-02-04 22:00

    It's because of your else if statements. You're checking with a single equal sign, which is assigning the value.

    if ( windowSize = 480 && windowSize <= 719 )
    

    when you should be doing

    if ( windowSize == 480 && windowSize <= 719 )
    

    or >=, if that's the intended logic.

提交回复
热议问题