Ravichandran Jothi Ravichandran Jothi - 6 months ago 28
jQuery Question

How to add a div when clicking a button in jquery?

I need to add the following div structure when i click button at every time?
I need to generate the following whole div structure at every time of clicking the button using jquery.

<div class="module_holder">
<div class="module_item">
<img src="images/i-5.png" alt="Sweep Stakes"><br>sendSMS

help me.



You need a container div that you can insert it into:

<div id="container"></div>

Then you can use the append() method of jquery:

$("#somebutton").click(function () {
  $("#container").append('<div class="module_holder"><div class="module_item"><img src="images/i-5.png" alt="Sweep Stakes"><br>sendSMS</div></div>');