JQuery Practice-making pages move

Source: Internet
Author: User

  1. Get and set element attributes
    Attribute attribute: Refers to a property in a DOM element that can correspond to an attribute in an HTML element. Usually the name of the JS attribute attribute matches the corresponding attribute one by one, but class "=" ClassName
    The action attribute or the action attribute depends on what you want to do and how you want to implement it.
    JQuery does not have specific commands to get or modify the awakening of elements. However, you can use native JS notation, access attributes and attribute values, and get an element reference first.
    each (iterator) Iterate through all the elements in the package set, calling the passed-in iterator function for each element separately The parameter is a function, and the function parameter is set to the subscript of the current element in the Security bureau , and the current element is this. Return to package set


    Reads the value assigned to the first element in the wrapper set specifying an attribute attr (name) Parameter string, name of the attribute no return undefined.
    Custom features can also be removed
    Sets the value passed in for the name attribute of all elements in the wrapper set attr (Name,value) Name: string
    Value: String | object | function
    function, the parameter is a 0-based subscript in the package set, this is the current element
    Packing set . attr (' disabled ', ' disabled ')
    Specify multiple attributes at once attr (attributes) An object that is copied to all elements of the wrapper set as attributes
    If the property value of the object in which the origin comes in is a function reference, then it is done in a way similar to the previous attr format, for
    Each element in the matching set calls the function separately
    Packing set
    Delete attribute REMOVEATTR (name) String Packing set








    A simple way to access common properties of jquery: Class, Cssfloat,flost,for,maxlength,readonly,stylefloat==>ie
  2. Action Element class name
    Modify element Style: Add CSS class or manipulate DOM, apply new style directly

    Adds the specified one or more class names to all elements of the wrapper set AddClass (names) A string that separates multiple classes with spaces Packing set
    Removes the specified class name or classes from each element of the package set Removeclass (names) A string with multiple class names separated by a space Packing set
    Toggle a set of styles Toggleclass (name) A string that contains the class name for the switch Packing set
    Sets the specified value to the specified CSS style property for each matched element CSS (Name,value) String
    string | number | function
    function, this
    Packing set
    Specify more than one CSS property value at a time CSS (properties) Property Object Packing set
    Gets the CSS property value specified by the first element name in the package set CSS (name) String Value
    Set width Width (value) numeric value in pixels Packing set
    Set height Height (value) numeric value in pixels Packing set
    Read width Width
    Read height Height
    Determines whether an element in the matching set has the class name specified by the passed name parameter Hasclass (name) String True/false Wapper.is (classname) <==>wapper.hasclass (classname)














  3. setting element content and modifying the DOM tree
  4. Gets the HTML content of the first element in the matching set HTML () The return value is the same as what the innerHTML property of that element is getting
    Sets the incoming HTML fragment to the contents of all matching elements HTML (text) String, HTML Fragment Packing set
    Concatenate all text contents of elements in the package set and return a string Text () A concatenated string
    Set text content Text (content) Text content. <==> &lt Packing set
    Appends an intrusive HTML fragment or element to the contents of all matched elements Append (conent) string | element | object Packing set If there is only one element in the wrapper set, the appended element is removed from the original location. If there are multiple elements in the wrapper set, the Append element backup is used to append. The original location also has
    Moves all elements in the package set to the end of the specified target content AppendTo (target) string | element Packing set If the destination identifies only one target element, the element is moved and if the destination identifies more than one target element, the source element remains in its original position and is copied to each target element
    Prepend (conent) Packing set
    Prependto (target) Packing set
    Before the target element is inserted before the first child element of the target element Before (content) Packing set
    InsertBefore (target) Packing set
    After (content) Packing set
    InsertAfter (target) Packing set $ (' <p>hi there</p> '). InsertAfter (' P img ')
    Wrap each element of the matching set with a cloned copy of the passed HTML tag or the passed element, respectively. Wrap (wrapper) string | element Packing set $ (' a.suprise '). Wrap (' <div class= ' Hello ' ></div>
    Wrap the elements of the matching set as a unit. Wrapall (wrapper) string | element Packing set
    Wrap the contents of a matching set of elements separately. Wrapinner (wrapper) string | element Packing set
    Remove all elements from the package set from the page Dom Remove () Packing set Elements removed from the DOM are still referenced by the wrapper set. Will not be recycled
    Clears the contents of all DOM elements in the matching set Empty () $ (' Div.ekementtoreplace '). After (' <p>xdfsd</p> '). Remove ()
    Creates a copy of the elements in the wrapper set, returning a new wrapper set Clone (Copyhandlers) True/false
    Replication Event handlers
    New Package Set






















  5. Working with FORM element values

    A form element refers to an element that has the name and value attributes that appear in a form

    Returns the value attribute of the first element in a match set Val () An array of values or values that have been obtained Throws an exception if the first element in the wrapper set is not a FORM element.
    check box, radio box, also returns the value attribute
    radio button:
    $ (' [name=radiogroup]:checked '). Val ()
    Set the value of a form Val (value) String Packing set

    Gets an array of values for the check box group
    Serializing elements in a package set
    Empty fields
    Convert DOM forms to AJAX-compatible formats
    Make a check box or radio button selected

    Select options within the <select> element

    Select the check box, radio button, or SELECT element's option to change to selected Val (values) An array of values Packing set As long as their values match any one of the values of the passed value array










JQuery Practice-making pages move

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.