循环repeater中的textbox,相加

循环repeater中textbox的值,并相加 

    var num = 0;

              function txt_change() {

                  $.each($("input:text[id*='txtgs']"), function (index, item) {

                       $(item).bind("keyup", function () {

                         $.each($("input:text[id*='txtgs']"), function (index, item) {

                             if ($.trim($(item).val()) != "") {

                                  if (!isNaN($.trim($(item).val()))) {

                                      num += parseInt($(item).val());

                                  } else {

                                      alert("请输入数字");

                             }

                           });

                       $("#lab_count").text(num);

                       });

                  });

 

                   $("#lbltotal").each(function () {

                       alert($("#lbltotal").length);

                  })

           }

 

posted on 2015-01-12 16:14  古月0320  阅读(158)  评论(0编辑  收藏  举报

导航