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

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

    Your condition is actually an assignment:

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

    You should be using ==:

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

提交回复
热议问题