首页 > 代码库 > 循环repeater中的textbox,相加

循环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);

                  })

           }

 

循环repeater中的textbox,相加