JQuery learning notes operations jQuery Object Property Processing

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.