html5 复选框 事件,Checkbox 对象属性和事件

Checkbox 对象属性和事件

HTML DOM Checkbox 对象

Checkbox 对象

Checkbox 对象代表一个 HTML 表单中的 一个选择框。

在 HTML 文档中 每出现一次,Checkbox 对象就会被创建。

您可以通过遍历表单的 elements[] 数组来访问某个选择框,或者通过使用 document.getElementById() 。

IE: Internet Explorer, F: Firefox, O: Opera, W3C: W3C 标准.

Checkbox 对象的属性

属性

描述

IE

F

O

W3C

设置或返回访问 checkbox 的快捷键。

4

1

9

Yes

设置或返回不支持 checkbox 时显示的替代文本。

5

1

9

Yes

设置或返回 checkbox 是否应被选中。

4

1

9

Yes

返回 checked 属性的默认值。

4

1

9

Yes

设置或返回 checkbox 是否应被禁用。

4

1

9

Yes

返回对包含 checkbox 的表单的引用。

4

1

9

Yes

设置或返回 checkbox 的 id。

4

1

9

Yes

设置或返回 checkbox 的名称。

4

1

9

Yes

设置或返回 checkbox 的 tab 键控制次序。

4

1

9

Yes

返回 checkbox 的表单元素类型。

4

1

9

Yes

value

设置或返回 checkbox 的 value 属性的值

4

1

9

Yes

标准属性

属性

描述

IE

F

O

W3C

设置或返回元素的 class 属性。

5

1

9

Yes

设置或返回文本的方向。

5

1

9

Yes

设置或返回元素的语言代码。

5

1

9

Yes

设置或返回元素的 title 属性。

5

1

9

Yes

Checkbox 对象的方法

方法

描述

IE

F

O

W3C

从 checkbox 上移开焦点。

4

1

9

Yes

模拟在 checkbox 中的一次鼠标点击。

4

1

9

Yes

为 checkbox 赋予焦点。

4

1

9

Yes

一、Checkbox 对象是什么?

The Checkbox object represents a checkbox in an HTML form. For each instance of an tag in an HTML form, a Checkbox object is created.

Checkbox对象可代表一个HTML表单中的checkbox(复选框)。每当有标签出现在HTML表单,一个Checkbox对象就建立起来了。

You can access a Checkbox object by indexing the elements array (by number or name) of the corresponding form or by using getElementById().

你可以通过元素数组索引或是使用getElementById()来访问Checkbox对象。

IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (互联网标准).

二、Checkbox 对象属性有哪些?

Property

属性 Description

描述 IE F N W3C

accept Sets or returns a list of content types, which the server processing this form will handle correctly

设置或返回内容的类型,让服务器更准确的处理这个表单 -     Yes

accessKey Sets or returns the keyboard key to access the checkbox

设置或返回能够访问这复选框的键盘按键。 4     Yes

align Sets or returns the alignment of the checkbox according to the surrounding text

设置或返回复选框相对周围文字的对齐方式 -     Yes

alt Sets or returns an alternate text to display if the browser does not support checkboxes

设置或返回对于那些无法支持checkbox浏览器的替换文字。 -     Yes

checked Sets or returns whether or not the checkbox is checked

设置或返回checkbox是否被选中了 3 1 2 Yes

defaultChecked Sets or returns the default value of the checked attribute (true if checked by default and false if not)

设置或返回被选中属性的默认值(被默认的选中则为真,不然则为假) 3 1 2 Yes

disabled Sets or returns whether or not the checkbox should be disabled

设置或返回复选框是否应该禁用。 3 1   Yes

form Returns a reference to the form that contains the checkbox

返回包含checkbox表单的参考 3 1 2 Yes

id Sets or returns the id of the checkbox (In IE 4 this property is read-only)

设置或返回checkbox的id(在IE4中这个属性只读) 4 1   No

name Sets or returns the name of the checkbox

设置或返回checkbox的name 3 1 2 Yes

tabIndex Sets or returns the index that defines the tab order for the checkbox

设置或返回checkbox由tab顺序所定义的索引 4     Yes

type Returns the type of the form element. For a checkbox it will be "checkbox"

返回表单元素类型,是checkbox的话就会返回为"checkbox" 4 1 3 Yes

value Sets or returns the value of the value attribute of the checkbox

设置或返回checkbox属性的值 3 1 2 Yes

标准属性

Property

属性 Description

描述 IE  F O W3C

className Sets or returns the class attribute of an element

设置或返回元素的class属性 5 1 9 Yes

dir Sets or returns the direction of text

设置或返回文字方向 5 1 9 Yes

lang Sets or returns the language code for an element

设置或返回元素的代码语言 5 1 9 Yes

title Sets or returns an element's advisory title

设置或返回元素的咨询标题 5 1 9 Yes

三、Checkbox 对象方法有哪些,怎么使用?

Method

方法 Description

描述 IE F N W3C

blur() Removes focus from the checkbox

删除checkbox的焦距 3 1 2 Yes

click() Simulates a mouse-click in the checkbox

在checkbox中模仿鼠标点击 3 1 2 Yes

focus() Gives focus to the checkbox

为checkbox加上聚焦 3 1 2 Yes

四、Checkbox Object Events有哪些?

checkbox对象事件

Syntax: object.event_name="someJavaScriptCode"

语法:对象.事件名 = "一些js代码"

Event

事件 Description

描述 IE F N W3C

onBlur Executes some code when the checkbox loses focus

当checkbox失去聚焦的时候执行一些代码 3 1 2

onClick Executes some code when the checkbox is clicked

当checkbox被点的时候执行一些代码 3 1 2

onFocus Executes some code when the checkbox gets focus

当checkbox得到聚焦的时候执行一些代码 3 1 2

onMouseDown Executes some code when a mouse button is pressed

当鼠标按钮按住的时候执行一些代码 4 1 4

onMouseUp Executes some code when a mouse button is released

当鼠标按钮释放的时候执行一些代码 4 1 4

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值