如何为 jQuery 列表视图中的特定链接创建单击事件. [英] How to create click event for specific link in a jQuery listview.
本文介绍了如何为 jQuery 列表视图中的特定链接创建单击事件.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试创建一个函数,该函数在您单击列表视图中的特定链接时启动.问题是当您单击链接时事件似乎没有触发.该列表是动态创建的.我不确定这是否会导致问题.
I'm trying to create a function that starts when you click on a specific link in a listview. The issue is that event doesn't seem to fire when you click the link. The list is created dynamically. I'm not sure if that causes an issue.
<label for="listviewForLastTenCalls">Last Ten Calls:</label>
<ul data-role="listview" id="listviewForLastTenCalls">
</ul>
<script>
$('#listviewForLastTenCalls li').click(function(){
//alert('click event handler fired');
</script>
推荐答案
<ul data-role="listview" id="listviewForLastTenCalls">
<!-- items dynamically generated -->
</ul>
JS
$(document).on('click', '#listviewForLastTenCalls li a', function () {
// code
});
这篇关于如何为 jQuery 列表视图中的特定链接创建单击事件.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文