0

I am new for javascript. I have one root div id is "row_logic" itself two div is there. how to increment this root div in below format using javascript?? anyone help.

 <div class="row-fluid" id="row_logic">
    <div class="col-sm-6" style="padding-top: 5px; padding-left: 5px; padding-right: 5px; border: 1px solid #373737;">
       <canvas id="b1" width="600" height="120"></canvas>
    </div>
    <div class="col-sm-6" style="padding-top: 5px; padding-left: 5px; padding-right: 5px; border: 1px solid #373737;">
       <canvas id="b2" width="600" height="120"></canvas>
    </div>
 </div>
6
  • Increment ? What do you mean ? Commented Jun 12, 2017 at 7:46
  • 2
    Question is unclear. Can you try reconstructing it. Also since you have tagged twitter-bootstrap-3 you are using Jquery as well in your page. So add that tag if you are open to receive help using Jquery as well. Commented Jun 12, 2017 at 7:46
  • You can look this: stackoverflow.com/questions/31919869/… Commented Jun 12, 2017 at 7:48
  • can you please tell me that what exactly you want to do? I mean are you want to create a row_logic div again or the div inside it. (canvas b3..b4..like that?) Commented Jun 12, 2017 at 7:53
  • you want to create div element with canvas id like b1,b2,b3,b4 ? Commented Jun 12, 2017 at 7:55

2 Answers 2

0

Here I'm using clone() method of jquery and clonning with the class.

<a href="#" id="btn">replicate</a>

Include jquery here

 $('#btn').click(function() {
            alert("Hello");
       $('.row-fluid').clone().insertAfter(".row-fluid");
    });

LINK : https://codepen.io/anon/pen/rweRKZ

Sign up to request clarification or add additional context in comments.

Comments

0
document.getElementById('row_logic').onclick = duplicate;

function duplicate() {
    var original = document.getElementById('row_logic');
    var clone = original.cloneNode(true); // clone
    original.appendChild(clone);
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.