js表單克隆

        var newForm = $("#componentForm").clone().removeAttr("style").attr("id","componentForm"+count);
        var newFormHtml = newForm.html().replace(/componentPrice\[0\]/g,"componentPrice["+count+"]");
        newFormHtml = newFormHtml.replace(/componentPriceMoney0/g,"componentPriceMoney"+count);
        newFormHtml = newFormHtml.replace(/total0/g,"total"+count);
        newFormHtml = newFormHtml.replace(/0/g,count);
        newFormHtml = newFormHtml.replace(/材料費\(1\)/g,"維修費("+(labelCount+1)+")");
        newForm.html(newFormHtml);
        newForm.find(".del").show();
        newForm.find('#price_label').text('費用');
        newForm.find('#price_label').next().children('.money').attr('placeholder', '請輸入維修費用');
        newForm.find('.price-type').val('維修費');
        $("#componentFormDiv").append(newForm);
        $("#componentPriceMoney"+count).parent().find("span").html("");
        $("#total"+count).html("");
        count++;
        labelCount++;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章