Check/Uncheck checkbox with JavaScript (jQuery or vanilla)?

后端 未结 12 1528
渐次进展
渐次进展 2020-11-22 09:39

How can a checkbox be checked/unchecked using JavaScript, jQuery or vanilla?

12条回答
  •  佛祖请我去吃肉
    2020-11-22 10:06

    I would like to note, that setting the 'checked' attribute to a non-empty string leads to a checked box.

    So if you set the 'checked' attribute to "false", the checkbox will be checked. I had to set the value to the empty string, null or the boolean value false in order to make sure the checkbox was not checked.

提交回复
热议问题