Attribute processing of Elements
Method |
Description |
Attr (name) Attr (name, value) Attr (name, fn (index, value )) Attr ({name1: value1,..., NameN: valueN }) |
Obtains the value of an attribute, or can be used to set the value of an attribute. You can also use a function as a parameter to set the function return value as the value of the element attribute. For example, you can set the name attribute of the element (index + 1) as the function return value (in fact, this is not required if you understand the function syntax ). You can also give multiple attributes to the same element at a time. |
RemoveAttr (name) |
Deletes the attribute value of an element. |
Element classAttribute Processing
Method |
Description |
Attr ("class ") RemoveAttr ("class ") |
Class is obviously an attribute, so attr () can be processed completely |
AddClass (value) |
Append one or more attribute values to the class attribute of an element. Multiple Attribute values. Values are connected by spaces. |
RemoveClass (value) |
Removes one or more attribute values for the class attribute of an element. |
ToggleClass (value) |
Controls the switching of one or more attribute values in the class attribute. If the attribute exists, it is deleted. If the attribute does not exist, it is added. |
HasClass (value) |
Returns a Boolean value to determine whether the element class attribute contains an attribute value. |
HTML, Text processing
Method |
Description |
Html () Html (value) Html (fn (index, value )) |
Obtain the HTML code inside the element, or set the HTML code inside the element. You can also use function parameters to use the return value as the HTML code that needs to be added inside the element. |
Text () Text (value) Text (fn (index, value )) |
You can obtain the text content inside the element or set the text content inside the element. However, this method not only replaces the original text content, but also replaces the child element. You can also use function parameters to specify the return value as the text content that needs to be added inside the element. |
Attribute processing of form elements
Method |
Description |
Val () Val (value) Val (fn (index, value )) Val ([value1,..., ValueN]) |
Obtain the value of the value attribute of a form element, or set the value of the value attribute of a form element. You can also use function parameters. You can also select form options with specific value attribute values. For select elements without radio and mutiple, only the last value in the val parameter is valid. |