亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

jQuery トラバーサル メソッド

each()メソッド:

$.each(配列/オブジェクト, 関數(shù)処理); //$オブジェクトが呼び出されました

$(セレクター).each(関數(shù)処理); //jqueryオブジェクトが呼び出されました


學(xué)び続ける
||
<!DOCTYPE html> <html> <head> <title>php.cn</title> <meta charset="utf-8" /> <script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script> <script> function f1(){ //① 遍歷對(duì)象 //$.each(對(duì)象,function(k對(duì)象屬性變量,v對(duì)象屬性值變量){}); var cat = {name:'kitty',age:5,climb:function(){console.log('在爬樹(shù)');}}; jQuery.each(cat,function(k,v){ console.log(k+'---'+v); }); //② 遍歷數(shù)組 //$.each(數(shù)組,function(k元素下標(biāo)變量,v元素值變量){}); var color = ['red','blue','green']; jQuery.each(color,function(m,n){ console.log(m+'---'+n); }); } window.onload = function(){ //③ 遍歷"jquery對(duì)象" //$('li').each(function(w dom對(duì)象下標(biāo)索引值,f代表具體的每個(gè)dom對(duì)象){}); $('li').each(function(w,f){ //this代表遍歷出來(lái)的每個(gè)“dom對(duì)象” //this ----> f //this ----> li對(duì)象(dom對(duì)象) console.log(w+"---"+f+"---"+this); f.style.color = "blue"; }); } </script> <style type="text/css"> div {width:300px;height:200px; background-color:pink;} </style> </head> <body> <h2>each遍歷方法</h2> <div id="apple"></div> <ul> <li>北京</li> <li>上海</li> <li>深圳</li> </ul> <input type="button" value="觸發(fā)1" onclick="f1()" /> </body> </html>
提出するリセットコード