[英]jquery 1.9.1 on event not working
随着Jquery v1.5.2以下功能的工作,我已经将jquery升级到1.9.1 live,已替换为on功能。 如果我改住就继续。 它不起作用。
我继续生活,并包括了迁移插件的工作原理。 我如何在on函数上使用它
$( ".pop-up" ).live(
"click",
function( event ){
// get the id of the item clicked on
var id = $(this).attr('id');
alert(id)
// block the href actually working
return( false );
});
尝试这个
如果以后将元素动态添加到DOM,则可以使用DOM中已经存在的选择器来代替文档。
$(function(){
$(document).on("click", ".pop-up",
function( event ){
// get the id of the item clicked on
var id = $(this).attr('id');
alert(id)
// block the href actually working
return( false );
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.