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, two parameter is the Set property value
-click the load image example
removeattr (attribute name)
-Delete the value of the property
Prop (Property name | property value)
-The return value of the property is a Boolean type
-Select, reverse, cancel examples
Removeprop (attribute name)
-Delete the value of the property
loops: Each (two examples of loops)
-$.each (Array/object, function (I, v) {})
-$ ("div"). each (function () {})
CSS Classes
-AddClass Add Class properties
-Removeclass Remove class properties
-Toggleclass Switch | Toggle (remove if available, no add)
Examples of light bulbs
HTML code/text/value
no parameter is to get the corresponding value,
set the corresponding value with parameters
-. HTML () to add HTML tags. html ("<span> la La. </span> ")
-. Text () to add texts. Text ("La La. ")
-. Val ()
input: A parameter that gets the value inside the input box
checkbox: A parameter that gets the value of
Select:
radio: Get Value
Multi-select: Get an array, set the time also if the array
One, attribute operation
1<! DOCTYPE html>234<meta charset= "UTF-8" >5<title> Properties Example </title>67<body>89<table border= "1" >Ten<tbody> One<tr> A<td>1</td> -<td> Martial Arts </td> -<td> Sales Department </td> the</tr> -<tr> -<td>2</td> -<td> Ah Gee </td> +<td> Finance Department </td> -</tr> +</tbody> A</table> at<form action= "" > -<input type= "checkbox" > -<input type= "checkbox" > -<input type= "checkbox" > -<input type= "Radio" > -<select name= "" Id= "" > in<option value= "" > Gansu </option> -<option value= "" > Lanzhou </option> to<option value= "" > Yongdeng </option> +<option value= "" > Tianshui </option> -<option value= "" > Qingyang </option> the</select> *</form> $<script src= "Jquery-3.2.1.min.js" ></script>Panax Notoginseng<script> - //$ ("img"). attr ("src", "bootstrap_i3.png"); the //$ ("table"). attr ("AAA"); + //$ ("table"). attr ("AAA", "On Time"); A</script> the</body> +ExampleIi. 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 OneLi = [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)//here, V 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 the text })</script>
Exit Loop ============================
Third, the attention of one of the following questions:
Workaround
---restore content ends---
jquery2--Property-related operations