Click here to Skip to main content
14,668,901 members
Rate this:
Please Sign up or sign in to vote.
how to add div when click on button using jquery or javascript ?
Posted
Updated 24-Feb-14 20:38pm
v2
Comments
Abhishek Pant 25-Feb-14 2:46am
   
why dont you take that div as a server control if you want to runat at runtime.
<div id="div1" runat="server">
your design code here
</div>
Sai Prasad anumolu 25-Feb-14 2:51am
   
it is not working abhishek

Rate this:
Please Sign up or sign in to vote.

Solution 4

Add the div and hide it,
once you click the button, unhide the div.
   
Rate this:
Please Sign up or sign in to vote.

Solution 1

   
Comments
Sai Prasad anumolu 25-Feb-14 1:40am
   
It it working?

My Question Is .. I designed
In the Division Like textboxs, Lables and addbutton

When i cliked add button Save the data in database After When i will click add button Same division will be open Other time ....
Rate this:
Please Sign up or sign in to vote.

Solution 5

You can use the following to create a div on runtime using Jquery with an id for further use.


var divNew = $(document.createElement('div')).attr('id', "div1");



$divNew.appendTo(document.body);



Above line will create a div with id= div1 and second line will append it to the document's end.
and you can use it further by referring to its id i.e. div1 .

Hope it will help. :)
   
v2
Rate this:
Please Sign up or sign in to vote.

Solution 3

Your question is not clear...do you want to open a pop up after saving your data to the database or what kind of division you want to open.
   
Comments
Sai Prasad anumolu 25-Feb-14 8:04am
   
open another division
Sanket Saxena 25-Feb-14 8:07am
   
Prasad paste your code with the correct and clear requirement
Sai Prasad anumolu 25-Feb-14 8:09am
   
Above text add divion
<div>
<asp:Button ID="btnDuplicate" Visible="false" Text="Duplicate" OnClick="btnDuplicate_Click" CssClass="btnCommon" runat="server" />
<asp:Button ID="btnAddAnotherText" Visible="false" Text="Add another Text Add" CssClass="btnCommon" runat="server" />

</div>
Sai Prasad anumolu 25-Feb-14 8:11am
   
This is code when i click add another text add ..

To display other division

<div id="TextAdds" runat="server" class="TextAdd Border">
<div style="color: #2b2b2b; font-size: 14px;">
Text Ads (Image Formats: Jpeg, Png, Gif) ($1/Text Ad or any equivalent currency)

</div>
<div style="height: auto;">
<div style="clear: both;"></div>
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<contenttemplate>
<div>
<table>
<tr>
<td>
<asp:FileUpload ID="FileTextAddsUpload" runat="server" />
<asp:Button ID="btnTextAddUpload" Text="Upload" OnClick="btnTextAddUpload_Click" CssClass="btnCommon" OnClientClick="ToggleDiv();" runat="server" />
</td>
<td>
<asp:Image ID="ImageTextAdd" CssClass="ImageDisplay" Visible="false" ImageUrl="imageurl" runat="server" /></td>
</tr>

</table>

</div>


<Triggers>
<asp:PostBackTrigger ControlID="btnTextAddUpload" />
</Triggers>



</div>

<div style="clear: both; padding-top: 8px;"></div>
<div>
<asp:TextBox ID="txtEnterChar" placeholder="Enter Text to display (Max Character Length - 160)" MaxLength="160" CssClass="txtMaxChar" runat="server" />

</div>
<div style="clear: both; padding-top: 12px;"></div>
<div>
<asp:Button ID="btnSave" Text="Save" Visible="true" OnClick="btnSave_Click" CssClass="btnCommon" runat="server" />
<asp:Button ID="btnClearEdits" Visible="true" OnClick="btnClearEdits_Click" Text="Clear Fields" CssClass="btnCommon" runat="server" />
<asp:Button ID="btnDelete" Visible="false" OnClick="btnDelete_Click" Text="Delete" CssClass="btnCommon" runat="server" />
<asp:Button ID="btnEdit" Visible="false" OnClick="btnEdit_Click" Text="Edit" CssClass="btnCommon" runat="server" />

<asp:Button ID="btnUpdate" Visible="false" Text="Update" OnClick="btnUpdate_Click" CssClass="btnCommon" runat="server" />
</div>
<div style="clear: both; padding-top: 10px"></div>


</div>
</div>
VICK 26-Feb-14 1:39am
   
Use the "Have a Question or Comment?" link next to the post if you have a question for the OP. By entering a solution you remove the question from the list of unanswered questions
Rate this:
Please Sign up or sign in to vote.

Solution 6

i used anchor tag It s working
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100