The common method of jquery's operation of Dom is to organize _jquery
Source: Internet
Author: User
jquery also has a great need for DOM operations.
1. Three simple and practical jQuery methods for DOM operations:
· Text ()-Sets or returns the textual content of the selected element
· HTML ()-Sets or returns the contents of the selected element (including HTML markup)
· Val ()-Sets or returns the value of a form field
2.attr () Get Properties。 Of course, these two can also set their own values to modify,
3. Add to HTML content。 Add New HTML Content
We'll learn four jQuery methods for adding new content:
· Append ()-Inserts the content at the end of the selected element
· Prepend ()-Inserts content at the beginning of the selected element
· After ()-Inserts the content after the selected element
· Before ()-Inserts content before the selected element
4. Delete element/content
The following two jQuery methods are generally available for deleting elements and content:
· Remove ()-Deletes the selected element (and its child elements)
· Empty ()-Deletes a child element from the selected element
5.jQuery Operation CSS
JQuery has several methods of doing CSS. We will learn the following:
· AddClass ()-add one or more classes to the selected element
· Removeclass ()-deletes one or more classes from the selected element
· Toggleclass ()-Toggle operation of the Add/Remove class to the selected element
· CSS ()-Sets or returns style properties
Example
$ ("H1,h2,p"). AddClass ("Blue"); first we know that when we add a style to a variety of tags we use ', ' to separate. Blue must be a set. blue{} class Selector
$ ("H1,h2,p"). Removeclass ("Blue");
$ ("H1,h2,p"). Toggleclass ("Blue"); the style will be removed, no style will be added
6. Set multiple CSS properties
To set up multiple CSS properties, use the following syntax:
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.