我有一个主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