单击jQuery中的按钮时如何添加div?

单击jQuery中的按钮时如何添加div?

问题描述:

每次单击按钮时,我需要添加以下div结构吗?
我需要在每次使用jquery单击按钮时生成以下整个div结构。

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
</div>
</div>

帮我。

感谢
Ravi

Thanks Ravi

您需要一个容器div,可以将其插入到其中:

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

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

然后可以使用jquery的append()方法:

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>');
});