Else statement not executed javascript

后端 未结 5 1604
执念已碎
执念已碎 2021-01-27 10:25

Hey Guys in the below code every time the if statement is executed no matter what the condition is.

function addRow(tableID) {

            var table = document.         


        
5条回答
  •  情歌与酒
    2021-01-27 10:50

    in your if statement:

    '=' should be '==' for starters
    

    then:

    (document.getElementById('select_degree').style.visibility == 'hidden')
    &&
    (document.getElementById('select_degree')!=null)
    

    you check a property before checking if it is null, if you switch them around the program will check null first, and if it is, drop to else, and not check the second condition.

    in this case, even if it is null, it is going to access .style.visibility

提交回复
热议问题