Web front End "11th" jquery Property related actions

Source: Internet
Author: User

Summary of Knowledge points

 1, Properties 
Property (if your selector selects multiple objects, the default is to return only the first property),

attr (Property name | property value)
-one parameter is the value of the Get property, and two parameter is the Set property value -click the load image Example
Removeattr (property name)
-delete the value of the property
Prop (property name | property value)
-Return of the property Value is Boolean type
-Radio, deselect, cancel example
Removeprop (property name)
-delete property's value

Loop: Each (two loop example)
-$.each (Array/object, function (I, v) {})
-$ ("div"). each (function () {})
CSS class
-AddClass Add Class Properties
-Removeclass Remove class attribute
-toggleclass Switch | Toggle (remove, no add)
Bulb example
HTML code/text/value
No parameters is to get the corresponding value,
have parameters to set the corresponding value
-. HTML () to add HTML tags. html ("<span> la La. </span> ")
-. Text () to add texts. Text (" Cheer up. ")
-. Val ()
Input: A parameter that gets the value inside the input box
checkbox: A parameter that gets the value of the values
Select:
Radio: Get Value
Multi-select: Get an array, set the time also if the array

One, property operation

<! DOCTYPE html>

Ii. Examples of pictures

1, attr

(1) Get properties and set property values

(2) Setting custom attribute values

  

2, Removeattr

  

3, prop

  

  

4, Removeprop

Third, the two ways of the cycle in jquery

    way One    li = [11,22,33];    $.each (Li,function (i,v) {        console.log (i,v)//0                         //1                         //2    })//    mode two    $ (". C1"). each ( function (i,v) {        console.log (i,v)//The  v here Gets the label//         0 <div class= "C1" >hah</div>//         1 <div class= "C1" > Year </div>//         2 <div class= "C1" > Eva </div>        console.log (v.innertext)  //Get text    }) </script>

Exit Loop ============================

Third, the attention of one of the following questions:

Workaround

Web front End "11th" jquery Property related actions

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.