jquery element properties and style actions, and setting elements and content

Source: Internet
Author: User

First, Jqury element property operation
jquery allows you to manipulate the attributes of the element itself, including getting property values for properties, setting property values for properties, and deleting attribute values (attr () and Removeattr ()).
Ii. jquery style operation
Element style actions include: setting CSS styles directly, adding CSS styles, category switching, and deleting categories.
For example:
$ (' div '). css (' color ');//Gets the CSS style color within the line of the element.
$ (' div '). css (' color '). ' Pink ');//Set my favorite pink.
var box = $ (' div '). css ([' Color ', ' height ', ' width ']);//This gets an array of objects.
By the way, the traversal of the array: two methods
First Kind
for (var i in box) {
Box[i];
}
The second Kind
$.each (Box,function (attr,value) {//Traverse JavaScript Primitive Ecological objects
attr+ ":" +value;
})
Define multiple styles for a div:

div style Click to toggle:

Iii. Introduction to JQuery Dom
In jquery, the most common dom manipulation methods have been encapsulated (without regard to browser compatibility).
D denotes document for the page
o represents an object, a set of data that contains independent attributes
M represents the model, which is the element nodes and text nodes on the page.
Dom has three forms, the standard DOM, Htmldom, and Cssdom, which do not need to be understood at this moment.
The tree structure used to represent the DOM is very pertinent. Most operations are element node operations, and a small number of text node operations.
Iv. Setting element content

jquery element properties and style actions, and setting elements and content

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.