checked

HTML checked Attribute (HTML选中属性)

The HTML checked attribute is a boolean attribute and specifies that an <input> element must be checked when the page loads.

You can use this attribute only on the <input> element (<input type=“checkbox”> and  <input type=“radio”>).

It is also possible to set the checked attribute after the page loads, with JavaScript. (也可以在页面加载后使用JavaScript设置checked属性。)

Syntax

Syntax (语法)

<input type="checkbox|radio" checked>

Example of the HTML checked attribute:

<!DOCTYPE html>
<html>
 <head>
   <title>Title of the document</title>
 </head>
 <body>
   <h2>HTML Form Example</h2>
   <form action="/form/submit" method="post">
     <input type="radio" name="game" value="football" checked> Football
     <input type="radio" name="game" value="basketball"> Basketball
   </form>
 </body>
</html>


请遵守《互联网环境法规》文明发言,欢迎讨论问题
扫码反馈

扫一扫,反馈当前页面

咨询反馈
扫码关注
返回顶部