input type=checkbox html元素,input type=checkbox HTML元素

定义

创建复选框控件。

Creates a check box control.

注释

当 INPUT type=checkbox 元素被选中时,将向 FORM 提交 name/value 的一对值。INPUT type=checkbox 的默认值是 on。

INPUT type=checkbox 元素的 height 和 width 样式是从 Internet Explorer 5 版本起实现的。元素的大小设置基于作者提供的值,除非给定的大小低于所需的最小值。大小的尺寸计算如下:

若 height 或 width 大于 20 像素,复选框四周的间隙 (padding) 将设置为 4 像素,内部高度或宽度将设置为 8 像素。

若 height 或 width 小于 20 像素但大于 13 像素,复选框四周的间隙 (padding) 将等于所指定的 height 或 width 减去 13 的差的一半。例如,若指定复选框的 width 是 17,四周间隙将是: (17-13)/2 = 2 像素。

若 height 或 width 小于 12 像素,复选框四周的间隙 (padding) 将设置为 0, 且内部宽度将设置为作者指定的值。

此元素在 Internet Explorer 3.0 及以上版本的 HTML 和脚本中可用。

此元素是一个内嵌元素。

此元素不需要关闭标签。

When an INPUT type=checkbox element is selected, a name/value pair is submitted with the FORM. The default value of INPUT type=checkbox is on.

The height and width styles are exposed to the INPUT type=checkbox element as of Internet Explorer 5. The size of the element is set based on the values provided by the author, except when a given size is below a particular minimum. The size is calculated as follows:

If the height or width is greater than 20 pixels, the padding around the check box is set to 4 pixels, and the inner height or width is set to 8 pixels.

If the height or width is less than 20 pixels but greater than 13 pixels, the padding around the check box is equal to one half the specified height or width minus 13. For example, if the specified width of the check box is 17, the equation would be: (17-13)/2.

If the height or width is less than 12 pixels, the padding around the check box is set to 0 and the inner width is set to the value specified by the author.

This element is available in HTML and script as of Internet Explorer 3.0.

This element is an inline element.

This element does not require a closing tag.

示例代码

下面的例子使用 INPUT type=checkbox 元素创建了两个带有解释文本的复选框。onclick 事件将调用两个脚本函数。第一个复选框默认选中。

This example uses the INPUT type=checkbox element to create two check boxes with explanatory text. The onclick events call two script functions. The first check box is checked.

Uncheck

this check box for some free advice.

Or check

this check box for a message from our sponsors.

下面的例子就是用户单击复选框时调用的脚本。

This example implements the script when the user clicks either check box.

function choosebox1(){

alert("Never play leapfrog with a unicorn!")

}

function choosebox2(){

SampText.insertAdjacentHTML("AfterBegin","Buy WonderWidgets! ");

}

另见

相关教程和示例代码

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值