prop(name|properties|key,value|fn)

prop(name|properties|key,value|fn)

Outline

Acquires the property value of the first element of a set of matched elements. Linear motor selection

With some of the DOM element or the built-in properties of the window object, if you try to remove the property, the browser may generate an error. jQuery first allocation undefined property values, while ignoring any errors generated by the browser

parameter

name String V1.6

Property Name

propertiesMapV1.6

As an attribute "name / value pairs" Object

key,valueString,ObjectV1.6

Property name, property value

key,function(index, attr)String,FunctionV1.6

1: attribute name.

2: function that returns the attribute values, the first parameter is the index of the current element, the second parameter is the original property value.

Examples

Parameter name Description:

Check the box to true, no check is false

jQuery code:
$("input[type='checkbox']").prop("checked");

Parameter properties Description:

Disable all check boxes on the page.

jQuery code:
$("input[type='checkbox']").prop({
  disabled: true
});

Parameters key, value Description:

Disable and check the box on all pages.

jQuery code:
$("input[type='checkbox']").prop("disabled", true);
$("input[type='checkbox']").prop("checked", true);

Parameters key, the callback function Description:

Set by function box on all pages are selected.

jQuery code:
$("input[type='checkbox']").prop("checked", function( i, val ) {
  return !val;
});

Guess you like

Origin www.cnblogs.com/furuihua/p/12002261.html