说三道四技术文摘-感悟人生的经典句子
说三道四 > 文档快照

fieldValue(successful)-JQuery API

HTML文档下载 WORD文档下载 PDF文档下载
fieldValue(successful)返回jQuery对象中field元素的值

fieldValue(successful)

返回jQuery对象中field元素的值。

 

If there is more than one field element in the jQuery object the value of the first successful one is returned. The successful argument controls whether or not the field element must be 'successful' (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls). The default value of the successful argument is true. If this value is false then the value of the first field element in the jQuery object is returned. Note: If no valid value can be determined the return value will be undifined. Note: The fieldValue returned for a select-multiple element or for a checkbox input will always be an array if it is not undefined.

 

返回值

String or Array<String>

 

参数

successful (Boolean): true if value returned must be for a successful controls (default is true) 

示例

说明:

Gets the current value of the myPasswordElement element

 

jQuery 代码:

var data = $("#myPasswordElement").formValue(); 

--------------------------------------------------------------------------------

 

说明:

Get the value of the first successful control in the jQuery object.

 

jQuery 代码:

var data = $("#myForm :input").formValue(); 

--------------------------------------------------------------------------------

 

说明:

Get the array of values for the first set of successful checkbox controls in the jQuery object.

 

jQuery 代码:

var data = $("#myForm :checkbox").formValue(); 

--------------------------------------------------------------------------------

 

 

说明:

Get the value of the select control

 

jQuery 代码:

var data = $("#mySingleSelect").formValue(); 

--------------------------------------------------------------------------------

 

 

说明:

Get the array of selected values for the select-multiple control

 

jQuery 代码:

var data = $("#myMultiSelect").formValue();

fieldValue(el, successful)

Returns the value of the field element. The successful argument controls whether or not the field element must be 'successful' (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls). The default value of the successful argument is true. If the given element is not successful and the successful arg is not false then the returned value will be null. Note: The fieldValue returned for a select-multiple element will always be an array.

 

返回值

String or Array<String>

 

参数

el (Element): The DOM element for which the value will be returned 

successful (Boolean): true if value returned must be for a successful controls (default is true) 

示例

说明:

Gets the current value of the myPasswordElement element

 

jQuery 代码:

var data = jQuery.fieldValue($("#myPasswordElement")[0]);

备案号:鲁ICP备13029499号-2 说三道四 www.s3d4.cn 说三道四技术文摘