为在js jquery中添加的标签添加点击事件
2017-11-02 09:26
489 查看
直接使用click事件是不起作用的,我平常使用的两种方法
1、on事件
var html1='';
html1 +=`<div>
<button type="button" class="btn btn-primary sure btn-mian" onclick="sure()">确认提交</button>
<button type="button" class="btn btn-default " data-dismiss="modal">暂不提交</button>
</div>`
$('.modal-footer').append(html1);
$('div').on('click','.sure',function(){console.log("+++");});
2、onclick事件
var html1='';
html1 +=`<div>
<button type="button" class="btn btn-primary sure btn-mian" onclick="sure()">确认提交</button>
<button type="button" class="btn btn-default " data-dismiss="modal">暂不提交</button>
</div>`
$('.modal-footer').append(html1);
functionsure(){console.logO("===");}
1、on事件
var html1='';
html1 +=`<div>
<button type="button" class="btn btn-primary sure btn-mian" onclick="sure()">确认提交</button>
<button type="button" class="btn btn-default " data-dismiss="modal">暂不提交</button>
</div>`
$('.modal-footer').append(html1);
$('div').on('click','.sure',function(){console.log("+++");});
2、onclick事件
var html1='';
html1 +=`<div>
<button type="button" class="btn btn-primary sure btn-mian" onclick="sure()">确认提交</button>
<button type="button" class="btn btn-default " data-dismiss="modal">暂不提交</button>
</div>`
$('.modal-footer').append(html1);
functionsure(){console.logO("===");}
相关文章推荐
- js实现冒泡事件,点击ul给子标签添加相同事件和阻止冒泡事件
- 使用JS或jQuery模拟鼠标点击a标签事件代码
- 使用JS或jQuery模拟鼠标点击a标签事件代码
- Jquery为DIV添加点击事件,Jquery为a标签超链接添加点击事件
- 通过js动态为标签元素添加点击事件
- 移动端点击a标签和img标签以及添加的js点击事件时的闪屏问题 解决方案
- 使用JS或jQuery模拟鼠标点击a标签事件代码
- 史上最全的CSS hack方式一览 jQuery 图片轮播的代码分离 JQuery中的动画 C#中Trim()、TrimStart()、TrimEnd()的用法 marquee 标签的使用详情 js鼠标事件 js添加遮罩层 页面上通过地址栏传值时出现乱码的两种解决方法 ref和out的区别在c#中 总结
- 使用JS或jQuery模拟鼠标点击a标签事件代码
- jquery给某个标签如<button>等,添加点击事件,$("#XX").click(function(){ });
- 使用JS或jQuery模拟鼠标点击a标签事件代码
- 使用JS或jQuery模拟鼠标点击a标签事件代码
- js添加标签以及事件和jQuery常用标签详解
- 使用JS或jQuery模拟鼠标点击a标签事件
- jquery给每个a标签添加点击事件
- 为什么jquery的点击事件在click事件下a标签选项卡会出现点击了没有任何反应?
- js 添加监听事件,包含jquery和DOM对象的转换
- jQuery添加options点击事件并传值
- Android 动态添加标签及其点击事件
- 总结:js点击事件 通过a标签ID进行删除书写错误