JQuery's operations on the DOM are also very important.
1. Three simple and practical jQuery methods for DOM operations:
text ()-Sets or returns the text content of the selected element
HTML ()-Sets or returns the selected Element (including HTML markup)
val ()-Sets or returns the value of the 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 ()-inserting content at the end of the selected element
prepend ()-inserting content at the beginning of the selected element
after ()-Inserts the content after the selected element
before ()-Inserts the content before the selected element
4. Delete element/content
If you want to delete meta Elements and content, you can generally use the following two JQuery methods:
Remove ()-Delete selected elements (and their children)
Empty ()-Remove child elements from selected elements
5.jQuer The Y action css
JQuery has several methods for CSS manipulation. We will study the following:
addclass ()-add one or more classes to the selected element
removeclass ()-Remove one or more classes from the selected element
toggleclass ()-pairs of selected elements Switch operations for Add/Remove classes
css ()-Set or Return style properties
Example
$ ("H1,h2,p"). AddClass ("Blue"); first we know when When adding styles to multiple tags, we use ', ' to separate them. Blue must be a set. blue{} class SelectionSelector
$ ("H1,h2,p"). Removeclass ("Blue");
$ ("H1,h2,p"). Toggleclass ("Blue"); a style is removed, and no style adds
6. Set multiple CSS Properties
If you want to set up multiple CSS genera , use the following syntax:
CSS ({"PropertyName": "Value", "PropertyName": "Value",...}); The
7.jQuery Dimension method
Jquerywidth () and Height () methods
Width () method sets or returns the width of the element (excluding the inner margin, border, or outside) Distance). The
Height () method sets or returns the height of the element (excluding the inner margin, border, or outer margin). The
Jqueryinnerwidth () and Innerheight () methods
Innerwidth () methods return the width of the element, including the inner margin. The
Innerheight () method returns the height of the element, including the inner margin. The
Jqueryouterwidth () and Outerheight () methods
Outerwidth () methods return the width of the element, including the inner margin and border. The
Outerheight () method returns the height of the element, including the inner margin and border.