- 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