copy Div block to another div

Posted by Rickeybglr under ASP.NET on 11/28/2012 | Points: 10 | Views : 2240 | Status : [Member] | Replies : 5
i have a div which have one 2text box 2 labels , and 1 button. i want to copy the whole div block to another div with new id's. plz suggest ??

<div id="div1">
//textbox , labels, etc
</div>

<div id="div2">
//wants to cpy here wid new ids
</div>




Responses

Posted by: Funda on: 11/28/2012 [Member] Starter | Points: 25

Up
0
Down
Uisng Jquery you can do this....

$("#div2").html($("#div1").html());

Rickeybglr, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rickeybglr on: 11/28/2012 [Member] Starter | Points: 25

Up
0
Down
i am new to jquery . do i need to include any file (js) for ths or any extensino??

Rickeybglr, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rickeybglr on: 11/28/2012 [Member] Starter | Points: 25

Up
0
Down
no not workin..
my code is here :
<script type="text/javascript">
function call() {

$("#div1").html($("#div2").html());

}

</script>

<div id="div1">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
<div id="div2">

</div>
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return javascript:call()" />

Rickeybglr, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pratyupalati on: 11/28/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,

<head runat="server">

<title></title>
<script src="jquery-1.8.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
$("#div2").html($("#div1").html());
$("#copy").click(function () {
$("#div2").html($("#div1").html());
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="div1">
<asp:TextBox ID="txt1" runat="server">
</asp:TextBox>
<asp:TextBox ID="txt2" runat="server"></asp:TextBox>
<asp:Label ID="lbl1" runat="server"></asp:Label>
<asp:Label ID="lbl2" runat="server"></asp:Label>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" />
</div>
<div id="div2">
</div>
<input type="button" value="ClickMe" onclick="document.getElementById('div2').innerHTML=document.getElementById('div1').innerHTML" />
</form>
</body>


Rickeybglr, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Funda on: 11/28/2012 [Member] Starter | Points: 25

Up
0
Down
function call() {
document.getElementById('div2').innerHTML = document.getElementById('div1').innerHTML;
}

<input id="Button2" onclick="return call()" type="button" value="button" />

Rickeybglr, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response