//Property access
$ (function () {//1. Manipulating text nodes: the text () method of the JQuery objectAlert ($ ("#bj"). text ()); $ ("#bj"). Text ("123")//2. Action attribute node: the attr () method of the JQuery object.//Note: Direct manipulation of the value property values can be done using the more convenient Val () method.Alert ($ (": Text[name= ' username ']"). attr ("value")); $ (: Text[name='username']). attr ("value","123");})
Inserting nodes
The test uses jquery to create the node and insert the node into the specified node
1. Create nodes: You can use the $ (HTML) method, element nodes, text nodes, and attribute nodes
$ (function () {//1. Create a <li id= ' id1 ' > Chongqing </li>//2. And add it to the #city sub-node$("<li id= ' id1 ' > Chongqing </li>"). AppendTo ($ ("#city"));$("#city"). Append ("<li id= ' id1 ' >[Chongqing]</li>")$("<li id= ' id1 ' > Chongqing </li>"). Prependto ($ ("#city"));$("#city"). Perpend ("<li id= ' id1 ' >[Chongqing]</li>") alert ($ ("#id1"). Text ())})
2. Inserting nodes
1. Create a <li id= "Id1" > Chongqing </li>
2. and add it to the back of #bj
$ ("<li id = ' ID1 ' > Chongqing </li>"). InsertAfter ($ ("#bj"))
$ ("#bj"). After ("<li id= ' id1 ' > Chongqing </li>");
Add in front
$ ("<li id = ' ID1 ' > Chongqing </li>"). InsertBefore ($ ("#bj"))
$ ("#bj"). Before ("<li id= ' id1 ' > Chongqing </li>");
jquery Learning-attribute access, inserting nodes