<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>jquery正反选</title> </head> <body> <p>ooo</p> <p>qqq</p> <p>www</p> <script src="/static/jquery.min.js"></script> <script> arr=[11,22,33] //用js写 for(var i=0;i<arr.length;i++){ $('p').eq(i).html(arr[i]) } //用jQuery写 方式一 {# $.each(arr, function (x,y) {//x是下标,y是值#} {# console.log(x)#} {# console.log(y)#} {# })#} //方式二 $('p').each(function () { console.log($(this)) $(this).html('hello') }) </script> </body> </html>