jQuery .click()不会在动态创建的链接上触发 [英] jQuery .click() not triggering on links dynamically created
本文介绍了jQuery .click()不会在动态创建的链接上触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
朋友们好,
我尝试使用以下脚本创建动态页脚并附加到MVC中的表
function createFooter(count){
var rowsPerPage = 5;
var footer =< tfoot>< tr>< td>;
for(var i = 1; i< count + 1; i ++){
footer = footer +< a class ='Paging'href =#> + i +< / a> ;
}
footer = footer +< / td>< / tr>< / tfoot>;
$('#DataTable thead')。after(footer);
返回页脚;
}
我正在尝试点击标签,但它不工作
我用过以下脚本
$('#DataTable tfoot a')。点击(function(e){
alert('hi');
e.preventDefault();
)};
知道它为什么不被解雇?
提前致谢
解决方案
('#DataTable thead')。after(footer);
返回页脚;
}
我正在尝试点击标签,但它不工作
我用过以下脚本
('#DataTable tfoot a')。click(function(e){
alert('hi');
e.preventDefault();
)};
Any想法为什么不被解雇?
提前致谢
对于jQuery 1.7+,请使用 [ ^ ]而不是点击
:
Hello friends,
I trying to create dynamically footer and append to the table in MVC using following script
function createFooter(count) { var rowsPerPage = 5; var footer = "<tfoot><tr><td>"; for (var i = 1; i < count + 1; i++) { footer = footer + "<a class='Paging' href=#>" + i + "</a> "; } footer = footer + "</td></tr></tfoot>"; $('#DataTable thead').after(footer); return footer; }
I'm trying to click the tag, but its not working
I have used following script
$('#DataTable tfoot a').click(function (e) { alert('hi'); e.preventDefault(); )};
Any idea why it is not getting fired??
Thanks in advance
解决方案
('#DataTable thead').after(footer); return footer; }
I'm trying to click the tag, but its not working
I have used following script
('#DataTable tfoot a').click(function (e) { alert('hi'); e.preventDefault(); )};
Any idea why it is not getting fired??
Thanks in advance
Hi,
For jQuery 1.7+, use on[^] instead ofclick
:
这篇关于jQuery .click()不会在动态创建的链接上触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文