单击jQuery中的按钮时如何添加div? [英] How to add a div when clicking a button in jquery?

查看:83
本文介绍了单击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>');
});

这篇关于单击jQuery中的按钮时如何添加div?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆