Jquery basic notes two (selector)

4. Selector: filter elements (tags) with similar characteristics

        1. Basic operation learning:
            1. Event binding
                //1. Get b1 button
                $("#b1").click(function(){                     alert("abc");                 });             2. Entry function                  $(function ( ) {                     }); The                  difference between window.onload and $(function)                      * window.onload can only be defined once, if it is defined multiple times, the latter will overwrite the former                      * $(function) can be defined multiple times.             3. Style control: css method                  // $("#div1").css("background-color","red");                   $("#div1").css("backgroundColor","pink");




                   






2. Classification
          1. Basic selector
                1. Tag selector (element selector)
                    * Syntax: $("html tag name") Get all the elements matching the tag name
                2. id selector 
                    * Syntax: $("#id的Attribute value") Get the element that matches the specified id attribute value
                3. Class selector
                    * Syntax: $(".class attribute value") Get the element that matches the specified class attribute value
                4. Union selector:
                    * Syntax : $("Selector1,Selector2....") Get all elements selected by multiple selectors
            2. Hierarchical selector
                1. Descendant selector
                    * Syntax: $("AB ") Select A element inside All B elements        
                2. Sub-selector
                    * Syntax: $("A> B") Select all B sub-elements inside A element
            3. Attribute selector
                1. Attribute name selector 
                    * Syntax: $("A[attribute name]") contains the selector with the specified attribute
                2. Attribute selector
                    * Syntax: $("A[attribute name='value']") contains the selector with the specified attribute equal to the specified value
                3. Compound attribute selector
                    * Syntax: $("A[attribute name='value'][]...") A selector containing multiple attribute conditions
            4. Filter selector
                1. First element selector 
                    * Syntax: :first Get the first element in the selected element
                2. Last element selector 
                    * Syntax: :last Get the last
                element in the selected element 3. Non-element selector
                    * Syntax: :not(selector) does not include the specified content Element of
                4. Even number selector
                    * Syntax: :even even number, counting from 0
                5. Odd number selector
                    * Syntax: :odd odd number, counting from 0
                6.Equal to index selector
                    * Syntax: :eq(index) specifies the index element
                7. Greater than the index selector 
                    * Syntax: :gt(index) is greater than the specified index element
                8. Less than the index selector 
                    * Syntax: :lt(index) is less than the specified index element
                9. Title Selector
                    * Syntax: :header Get the heading (h1~h6) element, fixed writing
            5. Form filter selector
                1. Available element selector 
                    * Syntax: :enabled Get available element
                2. Unavailable element selector 
                    * Syntax: :disabled Get the unavailable element
                3. Select the selector 
                    * Syntax: :checked Get the element selected by the radio/check box
                4. Select the selector 
                    * Syntax: :selected Get the element selected by the drop-down box

 

Guess you like

Origin blog.csdn.net/SSbandianH/article/details/109799628