This article is a mirror article of machine translation, please click here to jump to the original article.

View: 14461|Reply: 1

[Jquery] jquery several common knowledge points

[Copy link]
Posted on 8/19/2015 9:13:20 PM | | |
1. Insert elements inside
  append element after the inside of the append element
  prepend element
2. Insert elements before and after the outside of the element
   after
   before
3. Delete the element
        empty() Deletes the inside of the element Empty the element
        remove(), the entire node is deleted


4. Attributes
   attr(name) to get the attribute value
   attr(name,value) sets the attribute value

   css(name), which gets the style value
   css(name,value) sets the style value

   val() gets the value value of the form element
   val(v) parameter, set the value

   html() to get thml
   html(h) Set the HTML content
   text() to get the text capacity of the element  
   text(t) sets the text content  

   addClass
   removeClass
   toggleClass




1. Page loading
        $(function(){

        });
2. Bind event
        bind(type,fn)


3,click,mouseover,mouseout,
  click(function(){
               
  }) bind event
       
  click() event to call the event

4, unbind(type)
  When you want to use a parameter, you can cancel the corresponding type of event
  If you don't want to parameter, you can cancel all events

5,
hover(),
toggle(), which controls the display and hiding of elements when there are no parameters
When there is a toggle(fn,fn2) parameter, the function is called sequentially after each click.






1. Basic selector
       
   ID                                 #
   Class                             .
   Label Selector Element Name
   Wildcards, find all elements *
   Between multiple selectors ,

2. Level selector
   Find all descendant elements space ancestor descendant (div p)
   Matching all child elements under a given parent > child (div>p) it finds the direct first-level child element
   Matches all next elements immediately after the prev element perv+next
   Matches all siblings elements after the prev element prev ~ siblings
3. Simple selector :
        Locate the first element :first
        The last element :last
        Find the number of elements (index value): eq(index) The index value starts from 0
        Even number: even
        Odd number: odd
        Elements greater than the index value: gt(index)
        Less than :lt
        Does not contain :not(selector)       
        Matches header elements such as h1, h2, h3       


4. Content filter selector.   :
        Elements containing text: contains()
        Find the empty element :empty
        Find the element that contains the child element :has(selector)
        Locate the non-empty element :p arent

5. Attribute Selector []
        Elements containing what attributes [attribute name]
        Find the element with what the attribute name is [attribute name=value]
        Attribute is not equal to how much [attribute name!=value]
        How much does an attribute contain [attribute name*=value]
        Attribute starts with what [attribute name ^=value]
        Ending with what [attribute name $=value]
        Combine attribute selectors to satisfy [attribute name][attribute name$=value][attribute name$=value]

6. Sub-element filter selector
        First child element: first-child
        Last :last-child       
        Match the Nth child or odd-even element under its parent element: nth-child(index/even/odd/equation)
        Find a child element that has only one child : only-child
7. Form selector       
        input     :input
                  :button
                  :text
                  :submit
                  :checkbox
                  :radio
                  :password
8. Form object
        :checked
        :selected
        :disabled
        :enabled
9. Visibility
        :hidden
        :visible

       






Previous:jquery uses ajax request database for provincial and municipal linkage
Next:Two jqery methods implement the swipe-to-image preview function
Posted on 11/18/2015 1:28:19 PM |
Awesome
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com