.each() 遍历数组和对象
最后更新于:2022-04-02 03:22:54
[TOC]
## .each()
语法:
```
jQuery.each( collection, callback(indexInArray, valueOfElement) )
```
### 遍历数组
```
$.each([52, 97], function(index, value) {
alert(index + ': ' + value);
});
```
### 遍历对象
```
var obj = {
"flammable": "inflammable",
"duh": "no duh"
};
$.each( obj, function( key, value ) {
alert( key + ": " + value );
});
```
';