欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jQuery each()小議

 更新時(shí)間:2010年03月18日 19:08:50   作者:  
jQuery each()小議,對(duì)于具體的使用方法, 可以參考腳本之家的下一篇文章。
復(fù)制代碼 代碼如下:

var arr1 = [ "one", "two", "three", "four", "five" ];
$.each(arr1, function(){
alert(this);
});

輸出:one two three four five
復(fù)制代碼 代碼如下:

var arr2 = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
$.each(arr2, function(i, item){ 參數(shù)的名字可以自己定義,each方法會(huì)根據(jù)第一個(gè)參數(shù)(arr2)的格式而判斷回調(diào)函數(shù)方法體語法的正確性
alert(item[0]);
});

輸出:1 4 7
復(fù)制代碼 代碼如下:

var obj = { one:1, two:2, three:3, four:4, five:5 };
$.each(obj, function(key, val) {
alert(obj[key]);
});

輸出:1 2 3 4 5
復(fù)制代碼 代碼如下:

$.each($("input:hidden"), function(){
alert(this.name);
});
$.each($("input:hidden"), function(){
alert(this.value);
});

跳出遍歷
復(fù)制代碼 代碼如下:

$(document).ready(
function test()
{ var index=0;
var arr1 = [[1, 4, 3], [4, 6, 6], [7, 20, 9]]
$.each(arr1, function(i,item){
if(i==1)
{
alert("點(diǎn)擊繼續(xù)下次遍歷");
return ; //return false ;則跳出遍歷
}
alert('索引'+i+'_'+item[0]);
});
})

相關(guān)文章

最新評(píng)論