Let's take an example of jquery's document operations today. The first example is as follows:
<! Doctype html >
< Html >
< Head >
< Style >
P{ Margin :8px ; Font-size : 16px ; }
. Selected { Color : Blue ; }
. Highlight { Background : Yellow ; }
</ Style >
< Script SRC = "Http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" > </ Script >
</ Head >
< Body >
< P Title = "12335666" > Jquery document operations </ P >
< P > Example </ P >
< P > This is the test document. </ P >
< Script > Add JS here Code </ Script >
</ Body >
</ Html >
1) selector. addclass (classname), add the specified class name for each specified object
Code: $ ("P: First"). addclass ("heiglight"), the result is the first element < P > Jquery document operations </ P > Highlighted
2) selector. After (content) inserts content after each Matching Element
Code: $ ("P: First"). After ('<p> test of inserting the after function </P> ')
3) selector. append (content) inserts content at the end of each matching element. Unlike after, append inserts content inside the element, inserts child elements, and after inserts sibling elements.
4) The content. appendto (target) function is the same as append, but the parameter location is different. It is easy to see from the above method.
5) selector. ATTR (attributename) gets the first matching attribute name
. ATTR (attributename, value) sets one or more attributes for the specified element.
Or. ATTR (attributename, function (index, ATTR) {}) If selector is a set element, index indicates the index value, starting from scratch.
Code: $ ("P: Last"). Text ($ ("p"). ATTR ('title') the content of the Last P element is modified.
6) selector. Before (content) and after implement the opposite function, which is to insert content in front of the element outside.
7) selector. Clone () deeply copies all content, including elements, child elements, and text nodes.
Code: $ ("P: First"). Clone (). appendto ($ ('P: last'). This inserts the first element into the last P element.
8. selector.css (propertyname) to obtain the style attribute value of the first element in the element set.
. CSS (propertyname, value) sets one or more attributes for the matching element.
The functional design of CSS and ATTR is similar.
..