How do I determine if a checkbox is checked?

前端 未结 9 2128
我在风中等你
我在风中等你 2020-11-27 05:23

For some reason, my form does not want to get the value of a checkbox... I am not sure if it is my coding or not, but when I try and alert() the value, I get

9条回答
  •  南笙
    南笙 (楼主)
    2020-11-27 06:17

    var elementCheckBox = document.getElementById("IdOfCheckBox");
    
    
    elementCheckBox[0].checked //return true if checked and false if not checked

    thanks

提交回复
热议问题