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

后端 未结 6 407
陌清茗
陌清茗 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:28

    The = is an assignment operation.

    The != is an inequality operator.

    The == is an equality operator.

    I guess what you need is the == operator. So replace your code with:

    if (document.getElementById("hiddenButton").style.visibility == "hidden") {
    

提交回复
热议问题