我有一個主div,其中包含多個div和文本框內。在該文本框內用戶鍵入內容。設置文本框內的文本複製div
用戶完成輸入內容後,我複製整個主div。但是,當我複製主div時,我只能複製除了文本框內的所有內容。
我這樣做的方式是在javascript中複製主div的html。如果有人能幫助我,我將不勝感激。
大師事業部是createmain1這裏
<div id="createmain1" class="createmainclass1">
<div id="leftbox1">
<!--<p>the preview left div</p>-->
<div id="createmain1leftframe1" style="height: 100%; background-repeat: no-repeat; width: 100%;">
<div id="createmain1leftframe2" style="height: 100%; background-repeat: no-repeat; width: 100%;">
<div id="createmain1leftframe3" style="height: 100%; background-repeat: no-repeat; width: 100%;">
<div id="createmain1leftframe4" style="height: 100%; background-repeat: no-repeat; width: 100%;">
<textarea id="lefttext1" spellcheck="true" maxlength="500" wrap="hard" style="width: 100%; font-family: 'GillSansLightRegular'; overflow:hidden; resize:none; font-size:20px; border:none; height: 100%; background-color:transparent" placeholder="Enter Text Here"></textarea>
</div>
</div>
</div>
</div>
</div>
<div id="rightbox1">
<!--<p>the preview right div</p>-->
<div id="createmain1rightframe1" style="height: 100%; background-repeat: no-repeat; width: 100%;">
<div id="createmain1rightframe2" style="height: 100%; background-repeat: no-repeat; width: 100%;">
<div id="createmain1rightframe3" style="height: 100%; background-repeat: no-repeat; width: 100%;">
<div id="createmain1rightframe4" style="height: 100%; background-repeat: no-repeat; width: 100%;">
<textarea id="righttext1" spellcheck="true" maxlength="500" wrap="hard" style="width: 100%; font-family: 'GillSansLightRegular'; overflow:hidden; resize:none; font-size:20px; border:none; height: 100%; background-color:transparent" placeholder="Enter Text Here"></textarea>
</div>
</div>
</div>
</div>
</div>
</div>
在那裏我複製的是,我寫
<div id="finalimage" style="background-color:lightcoral" ></div>
JavaScript是
$("#Preview").click(function() {
var firstdiv = $("#createmain1").html();
var lefttext = $("#lefttext1").val();
$("#finalimage").css("height", "310px");
$("#finalimage").css("width", "460px");
$("#finalimage").html(firstdiv);
$("#finalimage").children("#leftbox1").css("height", "300px");
$("#finalimage").children("#leftbox1").css("width", "225px");
$("#finalimage").children("#leftbox1").css("float", "left");
$("#finalimage").children("#rightbox1").css("height", "300px");
$("#finalimage").children("#rightbox1").css("width", "225px");
$("#finalimage").children("#rightbox1").css("float", "left");
$("#finalimage").children("#lefttext1").val(lefttext);
}
只是一個指針,但沒有,也從未去過,一個「文本框」元素。永遠。它不存在,儘管人們似乎相信,莫名其妙地相信。你可以有'',或'',但這與現在一樣接近。 – 2013-05-10 15:42:02