<Divclass= "box"> <Divclass= "Box1"></Div> <Divclass= "Box2"> <Pclass= "P1"> <ulclass= "Ul3"> <Li>List Item 4</Li> <Li>List Item 5</Li> <Li>List Item 6</Li> </ul> <ulclass= "Ul4"> <Li>List Item 1</Li> <Li>List Item 2</Li> <Li>List Item 3</Li> </ul> </P> </Div> <Divclass= "Box3"> <Pclass= "P2"></P> <ulclass= "UL1"> <Li>List Item 1</Li> <Li>List Item 2</Li> <Li>List Item 3</Li> </ul> </Div> <ulclass= "Ul2"> <Li>List Item 4</Li> <Li>List Item 5</Li> <Li>List Item 6</Li> </ul> <formAction=""> <inputtype= "checkbox"name= "Newsletter"value= "Hot Fuzz" /> <inputtype= "checkbox"name= "News"value= "Cold Fusion" /> <inputtype= "checkbox"name= "Accept"value= "Evil plans" /> </form></Div>
the basics of jquery:
selector:
1 levels of:
$ (. Box ul)--get descendants of Ul1 and Ul2.
$ (. Box > UL)--just get a subset of it to get only the UL2 to the
$ (. BOX3 + ul)--(get adjacent sibling elements) just get ul2 to
$ (. Box1 ~ Div)--(this gets the same level of sibling) gets to the Box2 box3
$ (. Ul1 li:first)-(Must be Li and then the first li~~ of the colon ul1) <li>list item 1</li>
$ (. Ul1 li:first-child)-(Must be Li and then the first li~~ of the colon ul1) <li>list item 1</li>
Console.log ($ ("div p:first")); Get the first P (. p1) object in the first div;
Console.log ($ ("div p:first-child")); the first P (. P1 and. P2) objects in all Div
Console.log ($ (". Box Ul:first-of-type")): [Ul.ul3, UL.UL1, Ul.ul2] refers to the first occurrence in a label that appears in all of the first, rather than in the order in which the notes are arranged.
$ (. UL1 li:last) (must be Li then colon ul1 last li~~) <li>list item 3</li>
$ (. ul1 li). GT (0)--is greater than index 0, which is 1 2 <li>list item 2</li> <li>list Item 3</li >
$ (. Ul1 li). It (2-> is less than index 3 that is 0 1 <li>list item 2</li> <li>list Item 3</li>
$ ("Div:has (P)"). AddClass ("test")->box2 p
$ ("input[name= ' accept ']"). attr ("Checked", true)
<input type= "checkbox" Name= "Accept" value= "Evil plans" checked = true/> Determine that input has a name=accept label. Set checked and checked = True
$ (input[value^ = ' news ')-> Find all input elements with value starting with ' News '
<input type= "checkbox" name= "Newsletter" value= "Hot Fuzz"/>
<input type= "checkbox" Name= "News" value= "Cold Fusion"/>
that's a lot of $ (input[value $ = ' News ') find all the input elements that end with ' news ' * $ (input[value * = ' news ') find All value with ' news ' all input elements
$ (input[id][!value = ' news ') find all input with ID and value not news
$ (": Text") This is the one-line text box that matches all
differentiate: eq nth-child get ()
$ (". Ul1 li:nth-child (2)") is a child starting from 1 <li>list item 2</li>
$ (". Ul1 li"). EQ (2)--is the child starting from 0 <li>list item 3</li>
$ (". Box"). Get (0) <==>$ (". Box") [0] jquery transformed to native: get the corresponding element object directly from the index
Selectors in jquery