Home >Web Front-end >JS Tutorial >jQuery $.each usage instructions_jquery

jQuery $.each usage instructions_jquery

WBOY
WBOYOriginal
2016-05-16 18:31:34984browse
Copy code The code is as follows:

var arr1 = [ "a", "b", "c" , "d", "e" ];
$.each(arr1, function(){
alert(this);
});

Output: a b c d e
Copy code The code is as follows:

var arr2 = [[1, 2, 3], [ 4, 5, 6], [7, 8, 9]]
$.each(arr2, function(i, item){
alert(item[0]);
});

Output: 1 4 7
Copy code The code is as follows:

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


jQuery each() brief discussion
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn