jQuery knowledge point notes (continuously updated)

jQuery syntax

1. Basic syntax: $ ("selector"). Action () * selector: find query elements, * acrion: perform operations on elements

 

2、jQuery ready函数:$(document).ready(function( ){   });

        Brief introduction: $ (function () {});

 

3. How to write the method : for example: click method: $ ("buton"). Click (function () {click operation});

 

4. The exchange of DOM elements and jQuery elements :

  DOM to jQuery: You can wrap the DOM element text into jQuery element by wrapping a layer of $ () $ (text)

  jQuery to DOM: Subscript $ ("text") [0] can be used to encapsulate jQuery element $ ("test") into DOM element

 

5. jQuery selector: Find HTML elements based on element id, class, type, attribute, attribute value, etc. All selectors start with a dollar sign

 a. Basic selector:

  ①Element selector (select elements based on element names): $ ("p")

  ② # id selector (select elements based on id): $ ("# text")

  ③. Class selector (select elements based on class): $ (". Text")

 b. Level selector:

  ①ancestor descendant selector (ancestor represents ancestors, descendant represents descendants), used to match all descendant elements under a given ancestor element: $ ("# main p")

    In addition, you can use the find () method to get all descendant elements of the specified element: $ ("# main"). Find ("p") = $ ("# main p")    

  ②parent> child selector (parent represents parent element, child represents child element), used to match all child elements under a given parent element: $ ("form> p")

    In addition, you can use the children () method to get the child elements of the specified element: $ ("form"). Children ("p") = $ ("form> p")

  ③prev + next selector (prev and next are two elements of the same level), used to match all next elements immediately after the prev element: $ ("div + img")

    In addition, you can use the next () method to get the next sibling element immediately next to the specified element, and the nextAll () method to get all the sibling elements after the specified:

   $("div").next("img") = $("div + img"),$("div").nextAll("img")

  ④element ~ siblings selector (element and siblings two elements share the same parent element), used to match all siblings elements at the same level of the element element: $ ("div ~ ul")

   In addition, you can also use the siblings () method to get all the sibling elements of the specified element: $ ("div"). Siblings ("ul") = $ ("div ~ ul")

 

6. Filter selector

  a. Simple filter: start with a colon to achieve a simple filtering effect

 

     

 

 

  b. Content filter: The content filter is to filter through the text content contained in the DOM element and whether it contains matching elements.

 

 

  

   C. Visibility selector: The visibility filter is to match the element using the element's visibility state

 

   d. Attribute selector of the form object: the state attribute of the form element (such as selected, unavailable, etc.) matching element

 

 

  e. Sub-element filter: The sub-element selector is to filter the sub-elements of a given element. The specific filtering conditions are determined by the type of selector.

 

7. Attribute selector: The attribute selector is used to filter objects through the attribute of the element as a filtering condition.

 

 

8. Form selector: The form selector is to match elements that often appear in the form. But the matched elements are not necessarily in the form.

 

 

 

Guess you like

Origin www.cnblogs.com/Raite/p/12630930.html