DOM Input Text 对象

Text 对象

The Text object represents a text field in an HTML form. For each instance of an <input type="text"> tag in an HTML form, a Text object is created.
Text 对象代表了HTML表单中的text field,每当HTML表单中出现<input type="text">标签就意味着Text 对象被建立起来了

You can access a Text object by indexing the elements array (by number or name) of the corresponding form or by using getElementById().
你可以从表单数组的数字或是名称来访问Text 对象,或是使用getELmentById()来访问它

IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Text 对象属性

Property
属性
Description
描述
IE FNW3C
acceptSets or returns a list of content types, which the server processing this form will handle correctly
设置或返回内容的类型,让服务器更准确的处理这个表单
-  Yes
accessKeySets or returns the keyboard key to access the text field
设置或返回能够访问 text field 的键盘按键。
4--Yes
alignSets or returns the alignment of the text field according to the surrounding text
设置或返回 text field 相对周围文字的对齐方式
-  Yes
altSets or returns an alternate text to display if the browser does not support text fields
设置或返回对于那些无法支持 text field 浏览器的替换文字。
-  Yes
defaultValueSets or returns the initial value of the text field
设置或返回 text field的初始值
312Yes
disabledSets or returns whether or not the text field should be disabled
设置或返回 text field是否应该禁用。
516Yes
formReturns a reference to the text field's parent form
返回包含 text field 表单的参考
312Yes
idSets or returns the id of the text field (In IE 4 this property is read-only)
设置或返回 text field的id(在IE4中这个属性只读)
41 No
maxLengthSets or returns the maximum number of characters in the text field
设置或返回 text field中最大限度字符数
416Yes
nameSets or returns the name of the text field
设置或返回 text field的name
312Yes
readOnlySets or returns whether or not the text field should be read-only
设置或返回 text field是否为只读
416Yes
sizeSets or returns the size of the text field
设置或返回 text field 的大小
316Yes
tabIndexSets or returns the tab order for the text field
设置或返回 text field由tab顺序所定义的索引
4  Yes
typeReturns the type of the form element. For a text object it will always be "text"
返回表单元素类型,是 text field的话就会返回为" text field"
313Yes
valueSets or returns the value of the value attribute of the text field
设置或返回 text field value属性的值
312Yes

Text 对象方法

Method
方法
Description
描述
IEFNW3C
blur()Removes focus from the text field
取消 text field的聚焦
412Yes
click()Simulates a mouse-click in the text field
模仿鼠标点击 text field
4  No
focus()Sets focus on the text field
让 text field 获得聚焦
312Yes
select()Selects the content of the text field
选中 text field 的内容
412Yes

Text 对象事件

Syntax: object.event_name="someJavaScriptCode"
语法:对象.事件名称=“一些JS代码”

Event
事件
Description
描述
IEFNW3C
onBlurExecutes some code when the text field loses focus
当 text field失去聚焦的时候执行一些代码
412 
onChangeExecutes some code when the text field loses focus and its value has altered
当 text field失去聚焦并且它的值发生变动的时候执行一些代码
312 
onClickExecutes some code when the user clicks the left mouse button in the text field
当用户在 text field中用鼠标左键点击时执行一些代码
4   
onFocusExecutes some code when the text field gets focus
当 text field获得聚焦的时候执行一些代码
312 
onKeyDownExecutes some code when a key is pressed in the text field
在 text field中有键按住的时候执行一些代码
414 
onKeyPressExecutes some code when an alphanumeric key is pressed in the text field
当 text field 中有键按下并释放后执行一些代码
414 
onKeyUpExecutes some code when a key is released in the text field
当 text field 中按键释放则执行一些代码
414 
onSelectExecutes some code when the current selection is changed in the text field
当 text field里当前选中的内容发生变化时执行一些代码
312 
onSelectStartExecutes some code when some text in the text field is selected
当 text field中一些文字被选中则执行一些代码
4   
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值