03-Manipulation of properties, attributes, and data for jquery objects

Source: Internet
Author: User

  • Actions on the properties, attributes, and data of jquery objects:
      • attributes (attributes) and properties: The value of the
        • attribute is a string. The value of the
        • property is not only a string, but can be a Boolean value, an object, a number. The properties and attributes of the
        • element are dynamically linked, and if the attribute exists in the DOM object, one changes and the other changes
        • if the attribute is already present in the DOM object, but the type is Boolean, then the attributes and properties will not be synchronized.
      • Properties of the action element:
        • Gets the value of the attribute: attr (name)
        • Setting the value of the attribute: attr (name,value) att R (attributes)
        • Delete attribute: removeattr (); Remove multiple attributes in the middle plus a space. Properties of the
      • action element:
        • Gets the value of the property: Prop (name)
        • Setting the value of the property: Prop (Name,value)  prop (properties)  
        • attribute is case-insensitive, attribute-sensitive
        • delete attribute: Removeprop ();
      • Store data in an element:
        • Gets the value of the data: data ([name])
        • Sets the value of the date: Name,value (object);
        • Delete data: Removedata ([name]);
        • The
        • determines whether the element is this data: HasData (' ele ');
  • To modify the style and content of a jquery object:
    • Add or modify Class:addclass (name);
    • Remove class: Removeclass (name);
    • The above method can define a function, but the return value requires one or more class names.
$ ('#demo'). addclass (function (index,classname) {          return'  Red';     })

      • Determine if there is a class: Hasclass (name);
      • Switch A class, have the delete, do not add: Toggleclass (name);
      • Gets or sets the style (the property needs to be quoted with a cross-bar, and the Hump is not): CSS (name,value);
      • Setting does not contain borders and padding and height: width () and height ();
      • Set the height containing the padding: Innerheight ();
      • Sets the height that contains padding and borders, which can be set to true to include margin: outerheight ();
      • Returns an element in the collection of objects, returning two values, the distance to the left and the top: offset ();
      • Returns the position (offset) of the matching element relative to the parent element: position ();
      • Set scroll bars: scrolltop () and scrollleft ();
      • Set content: HTML () sets the value of the HTML, gets only one of the collection's, text () settings, and the collection gets all the values.

03-Manipulation of properties, attributes, and data for jquery objects

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.