首页 > Web开发 > 详细

jquery-遍历each

时间:2015-10-21 13:55:52      阅读:238      评论:0      收藏:0      [点我收藏+]

使用案例一

    $.ajax({
        url : webPath + "/clickCount",
        type : "POST",
        dataType : "json",
        data : {
            ids : ids
        },
        success : function(data) {
            var arr = data.list;
            $.each(arr, function(i, value) {
                for (var j = 0; j < news.length; j++) {
                    if (news[j].idStr == arr[i].newsID) {
                        $("#" + arr[i].newsID + "count").text(
                                arr[i].totalCommentCount);
                        $("#" + arr[i].newsID + "clickCount").text(
                                arr[i].weekClickCount);
                    }
                }
            });
        }
    });

 

$("button").click(function(){
  $("li").each(function(){
    alert($(this).text())
  });
});

each() 方法规定为每个匹配元素规定运行的函数。

提示:返回 false 可用于及早停止循环。

function(index,element)

必需。为每个匹配元素规定运行的函数。

  • index - 选择器的 index 位置
  • element - 当前的元素(也可使用 "this" 选择器)

 

jquery-遍历each

原文:http://www.cnblogs.com/hwaggLee/p/4897508.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!