Why does != work and just = doesn't?

后端 未结 6 413
陌清茗
陌清茗 2021-01-29 15:41

Here\'s my code:

  if (document.getElementById(\"hiddenButton\").style.visibility != \"visible\") {
     document.getElementById(\"hiddenButton\").style.visibili         


        
6条回答
  •  隐瞒了意图╮
    2021-01-29 16:41

    Left = Right

    This means, "Whatever the right side is, put it as the value for the left side."

    All comparisons and other checks are done with two symbols to limit ambiguity and improper variable assignments when you simply meant to check a value.

    != means not equal to
    == means equal
    === means equal and same object/datatype
    = means "Assign the right side (Or what it evaluates to) to the variable on the left
    

提交回复
热议问题