Click here to Skip to main content
15,843,145 members
Please Sign up or sign in to vote.
3.40/5 (3 votes)
how to add div when click on button using jquery or javascript ?
Updated 24-Feb-14 21:38pm
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
Sai Prasad anumolu 25-Feb-14 2:51am    
it is not working abhishek

Add the div and hide it,
once you click the button, unhide the div.
Share this answer
Share this answer
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 ....
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");


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. :)
Share this answer
Your question is not you want to open a pop up after saving your data to the database or what kind of division you want to open.
Share this answer
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
<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" />

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



<asp:PostBackTrigger ControlID="btnTextAddUpload" />


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

<div style="clear: both; padding-top: 12px;"></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 style="clear: both; padding-top: 10px"></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
i used anchor tag It s working
Share this answer

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

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900