IF Statement Always True

元气小坏坏 提交于 2019-11-26 21:02:33

You need to use == or === for comparison instead of =.

  • x = y assigns y to x
  • x == y checks if y and x are loosely equal
  • x === y checks if y and x are equal and of the same type

So what you need to do is replacing if (hv.val = "1") with if (hv.val == "1")

you wrote

if (hv.val = "1")

but this is an assignment (evaluated as true, in your code): check for equality is == (equality by value) or === (equality by value and type)

you have used = operator which is used for assignment for comparison == operator is used try this In your if statement try this

if(hv.val=="1")
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!