亲宝软件园·资讯

展开

js中复制行和删除行的操作实例

人气:0
复制代码 代码如下:

var validateForm = null;
  var num = 2;
  $(document).ready(function(){

   var lastCommunAddTr = $("#workDay");

   $("#add").click(function() {

         //复制一行
               var tr = $("#workDay").clone();
               tr.find("#dayMsg1").get(0).style.display="none";
                 tr.find("#remarkMsg1").get(0).style.display="none";
               tr.find("#msg1").get(0).style.display="none";
                tr.find("#day1").get(0).value="";
                tr.find("#dayMsg1").get(0).id="dayMsg"+num;
                tr.find("#day1").get(0).id="day"+num;
                tr.find("#msg1").get(0).id="msg"+num;
                tr.find("#remark1").get(0).value="春节";
               tr.find("#state1").get(0).id="state"+num;
              tr.find("#remark1").get(0).id="remark"+num;
              tr.find("#remarkMsg1").get(0).id="remarkMsg"+num;
               tr.show();
               tr.insertAfter(lastCommunAddTr);
               lastCommunAddTr = tr;
               num++;

            });

            //删除一行
            $("#workDayDel").click(function() {
                var delIndexs = new Array(0);

                $(".trWorkDay:gt(0)").each(function(i) {

                 if($(this).find("#ck").get(0).checked == true){
                  delIndexs.splice(delIndexs.length,0,i);
                     $(this).remove();
                    }
                     $(".trWorkDay").each(function() {

                 lastCommunAddTr = $(this);
                });
                });
            });
  });

加载全部内容

相关教程
猜你喜欢
用户评论