What is the syntax for boolean attributes, e.g. a checked checkbox, in HTML?

前端 未结 9 1445
故里飘歌
故里飘歌 2020-12-05 18:09

Sounds like a bit of a silly question, but I am wondering what is the best way of stating that a checkbox is checked/unchecked in HTML.

I have seen many different ex

9条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-05 18:45

    A quick test reveals that jQuery equates any value set to being checked.

    alert( $('input:checked').length );
    // Returns 5
    

    Even an empty string and the negative values.

提交回复
热议问题