Basic Operation {DOM}
The-html () method is similar to the DOM innerHTML
Get HTML ()
Set (Modify) HTML (HTML)
1 <button>0</button> 2 Span style= "COLOR: #008080" > 3 <script src= "js/jquery-1.11.3.js" ></script> 4 <script> 5 $ (' button '). Click (function () { 6 var intvalue = parseint ($ (this ) . HTML ()); 7 intvalue++; 8 $ (this 9 }) 10 </script>
The-val () method is similar to the value in DOM
Get Val ()
Set (Modify) Val (value)
12Unit: <span id= "Price" >3.5</span>3 Quantity:4<button id= "btless" >-</button><input name= "Count" value= "1" style= "width:30px" ><button id= " Btmore ">+</button>5 Subtotal :6<input name= "Total" value= "3.5" disabled>7 89 User name:Ten<input name= "UserName" ><br> One User gender: A<input type= "Radio" name= "Usersex" value= "male" >male -<input type= "Radio" name= "Usersex" value= "female" checked>female -<br> the Your city: -<select name= "City" > -<option value= "BJ" > Beijing </option> -<option value= "sh" > Shanghai </option> +<option value= "ZJ" > Zhejiang </option> -</select><br> + Hobbies and Interests: A<input type= "checkbox" name= "hobby" value= "XY" >Laundry at<input type= "checkbox" name= "hobby" value= "ZF" >Cooking -<input type= "checkbox" name= "hobby" value= "SD" > Sweep <br> - -<input type= "button" value= "Submit Order" id= "Btsubmit" > - - in -<script src= "Js/jquery-1.11.3.js" ></script> to<script> +$ (' #btLess '). Click (function(){ - varCount = $ (' [name= ' count '] '). Val (); theCount =parseint (count); *count--; $$ (' [name= ' count '] '). Val (count);Panax Notoginseng //Calculate Subtotal - varPrice = $ (' #price '). html (); the$ (' [name= ' total '] '). Val (price*count); + }) A$ (' #btMore '). Click (function(){ the varCount = $ (' [name= ' count '] '). Val (); +Count =parseint (count); -count++; $$ (' [name= ' count '] '). Val (count); $ //Calculate Subtotal - varPrice = $ (' #price '). html (); -$ (' [name= ' total '] '). Val (price*count); the }) - Wuyi$ (' #btSubmit '). Click (function(){ the //collect input from users - varn = $ (' [name= ' UserName "] '). Val (); Wu vars = $ (' [name= ' Usersex "]:checked ')). Val (); - //var c = $ (' option:selected '). Val (); About varc = $ (' select[name= ' City "]). Val (); $Console.log (n+s+c); - - //Note The Get of the check box multiple values - //var h = $ (' [name= ' hobby "]:checked '). Val (); A varJqobj = $ (' [name= ' hobby ']:checked '); + for(vari=0; i<jqobj.length; i++){ the varCB =Jqobj[i]; - varh =$ (CB). Val (); $ Console.log (h); the } the }); the</script>
The-attr () method is similar to GetAttribute () in the DOM;
SetAttribute ();
Get attr (property name)
Set (Modify) attr (property name, property value)
12345 67 89 Ten<script src= "Js/jquery-1.11.3.js" ></script> One<script> A$ ('. Thumbnail '). MouseEnter (function(){ - varalt = $ ( This). attr (' Alt '); -$ ('. Full-img '). attr (' src '), alt); the }); -</script>
jquery Operation Dom-parsing HTML elements