国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

jQuery traversal method

each() method:

$.each(array/object, function processing); //$Object The

$(selector) called. each(function processing); //jquery object called

<!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('在爬樹');}};

        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代表遍歷出來的每個(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>


Continuing Learning
||
<!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('在爬樹');}}; 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代表遍歷出來的每個(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>
submitReset Code