jQuery .click()无法正常工作吗? [英] jQuery .click() not working?
本文介绍了jQuery .click()无法正常工作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我按如下所示在html表中生成一组按钮,然后单击它时要调用函数.
I generate the set of buttons within html table as follows and then I want to call to function when it click.
$.each(childData, function(key, item) {
var packPath = key.replace(/_/g, "/"); //Replace underscore with slash
div.innerHTML = div.innerHTML + '<td>'+key+'</td>'
+ '<td><button type="button" data-id="'+key+'" class="download btn btn-success btn-xs">Originals</li></td></div>';
})
这是我调用该函数的方式,但是它不起作用.
This is how I call the function but it's not working.
$(".download").click(function(){
alert();
});
上面的代码哪里出问题了?
Where is the wrong in above code?
推荐答案
尝试一下:
$(document).on('click', '.download', function(){
// Your Code
});
这篇关于jQuery .click()无法正常工作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文