jquery properties and Styles ——. att () and. Removeattr ()

Source: Internet
Author: User

1 each element has one or more attributes that are used to give additional information about the element or its contents, such as: In an IMG element, SRC is the attribute of the element, and the address that marks the image

2 main DOM methods for operating characteristics

GetAttribute method

SetAttribute method

RemoveAttribute method

3 jquery uses the attr () method to get and set element properties, attr is an abbreviation for attribute (attribute)

4 Expression of attr ()

attr (incoming property name) Gets the value of the property

Attr (property name, property value) sets the value of the property

Attr (property name, function value) sets the function value of the property

attr (attributes) sets multiple attribute values for the specified element, that is (attribute name one: "Attribute value one", property name Two: "Property value Two", ...). )

5 removeattr () removes a property from each element in the collection of matching elements

6 attr, removeattr are jquery in order to attribute operations encapsulation, directly on the jquery object call the method, it is easy to manipulate the property, do not need to deliberately understand the browser's property name of the different problems

7 There is a concept in the DOM, attribute and property translation are attributes, in the "JS Advanced Programming" in the translation of attributes and attributes,attribute is the DOM node's own properties

8 Get attribute need to use attr, get property need to use prop

jquery properties and Styles ——. att () and. Removeattr ()

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.