jQuery中的循環


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Title</title>
<meta charset="UTF-8">
<script src="jquery-3.4.1.js"></script>
</head>
<body>
<script>
//1.jquery中的循環,example1
li=[11,22,33,44];
$.each(li,function(a,b){
console.log(a,b);
// });
// 結果:
// 0 11
// 1 22
// 2 33
// 3 44
//2.example2
dic={'firstname':'Lai','lastname':'star'}
$.each(dic,function (a,b) {
console.log(a,b);
})
//結果:
// firstname Lai
// lastname star
</script>

</body>
</html>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM