Click here to Skip to main content
15,793,452 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi I have a large div and I want to add it when I click the button like this:

Main div with button:
<html xmlns="">
<head runat="server">
    <script type="text/javascript" src="JavaScript/jquery-1.7.2.js"></script>
    <script type="text/javascript" src="JavaScript/jquery.sparkline.js"></script>
    <script type="text/javascript" src="JavaScript/jquery-ui-1.8.21.custom.min.js"></script>
    <div id="divMain">
        <label id="lblTitle">Add Here ...</label>
    <input type="button" id="btnAddControl" value="Add Control"/>
    <script type="text/javascript">
        $("#btnAddControl").click(function () { $("#divMain").append("<br/><div id='New'>New</div>")});

And this is the div I want to be in the main div:
<div class="divTable">
    <div class="divRow">

        <div class="divCell">
            <input type="text" id="lable" value="something" readonly="readonly"/>
            <button id="help-icon" style="width:13px ; height:13px">help</button>
            <div id="pop-up" class="divCell">
                loading...Say what u want!

        <div class="divCellmine">
            <label for="amount1">min:</label>
            <input type="text" id="amount1" style="border:0; font-weight:bold;" />
           <div class="divCellmine">
        <div id="slider-range" style="width: 142px; height: 1px"></div>
        <div class="divCellmine">
            <label for="amount2">max:</label>
            <input type="text" id="amount2" style="border:0; font-weight:bold;" />

Sandeep Mewara 4-Jul-12 2:19am    
And the issue is?
namneet singh 8-Jun-22 3:24am    
Sibasisjena 13-Jul-12 9:24am    
Hi bahar_Agi,
write the javascript coding in <head></head>.
It is better and the proper way.
vinodkumarnie 21-Mar-13 3:28am    
Whats happening with your code..?

You might want to give the .divTable an id.

You should include the .divTable in the DOM from the start

Set it's style to display:none;

On Click
var $dt = $(".divTable");
var $dm = $("#divMain");
// or
$dt.css('display', 'block'); // or inline or whatever
Share this answer
Share this answer
shyam ji 16-Aug-14 5:59am    
Great example, Thanks

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