jquery复制当前tr行

 //复制
        var vBudgetCompileObj = (function() {
            /*table新增/移除行,参数:tableId*/
            var getMaxIndex;
            var funGenerateRow = function(tableId) {
                $("a[name='CopyTr'],a[name='DelTr']").unbind("click").click(function() {
                    var index = getMaxIndex() + 1;
                    console.log("index:" + index);
                    if ($(this).attr("name") == "CopyTr") {
                        var newHidden = $('<input type="hidden" name="tbBudCode.index" value="' + index + '">');
                        var newTr = $('<tr>').addClass("tr_row");
                        newTr.html($(this).parents('tr').html());
                        $('select', newTr).next('div').remove();
                        $(this).parents('tr').after($(newTr));
                        newTr.before(newHidden);
                        /*循环 修改input控件id和name*/
                        newTr.find("input.eaBudcode").each(function () {
                            $(this).attr("id", "tbBudCode" + index );
                            $(this).attr("name", "tbBudCode" + index );
                        });
                        newTr.find("input.eaClientCode").each(function () {
                            $(this).attr("id", "tbClientCode" + index);
                            $(this).attr("name", "tbClientCode" + index);
                        });
                        newTr.find(".eaBudName").each(function () {
                            $(this).attr("id", "tbBudName" + index);
                            $(this).attr("name", "tbBudName" + index);
                        });

                        /*循环修改select控件的value、id和name*/
                        newTr.find("select.eaDept").each(function () {
                            $(this).attr("id", "ddlDept" + index);
                            $(this).attr("name", "ddlDept" + index);
                        });
                        newTr.find("select.eaBrand").each(function () {
                            $(this).attr("id", "ddlBrand" + index);
                            $(this).attr("name", "ddlBrand" + index);
                        });
                        newTr.find("select.eaBudItem").each(function () {
                            $(this).attr("id", "ddlBudItem" + index);
                            $(this).attr("name", "ddlBudItem" + index);
                        });
                        newTr.find("select.eaCompany").each(function () {
                            $(this).attr("id","ddlCompany"+ index);
                            $(this).attr("name","ddlCompany"+ index);
                        });
                        newTr.find("select.eaCurrency").each(function () {
                            $(this).attr("id", "ddlCurrency" + index);
                            $(this).attr("name", "ddlCurrency" + index);
                        });
                        $('select', newTr).chosen({ width : '100%' }); //初始化复制行下拉框   
                        funGenerateRow(tableId);
                    } else {
                        if (confirm("是否删除?")) {
                            $(this).parents('tr').remove(); //移除行                                            
                        }
                    }
                    //显示行号          
                    var thisIndex = 0;
                    $("#" + tableId + " tbody>tr.tr_row").each(function() {
                        var $td = $(this).children('td');
                        thisIndex++;
                        var thisRowIndex = $('<span class="badge badge-info">' + thisIndex + '</span>');
                        $td.eq(0).html(thisRowIndex);
                    });
                });
            }