Jquery mobile JQuery移动动态按钮添加单击
我在谷歌地图上有一个信息窗口Jquery mobile JQuery移动动态按钮添加单击,jquery-mobile,Jquery Mobile,我在谷歌地图上有一个信息窗口 var content = '<div id="link"><input type="button" value="Report this light" id="reportBtn"/></div>'; 您需要使用事件委派。试一试 $(document).on('pageinit',function(){ $(文档)。在('单击','报告BTN',函数()上{ 警报(“它工作”); }); }); 您可以使用最近的静态元素,而
var content = '<div id="link"><input type="button" value="Report this light" id="reportBtn"/></div>';
您需要使用事件委派。试一试
$(document).on('pageinit',function(){
$(文档)。在('单击','报告BTN',函数()上{
警报(“它工作”);
});
});
您可以使用最近的静态元素,而不是文档
,该元素是
的父元素
$(document).on('pageinit', function() {
$('#reportBtn').on('click', function() {
alert('it works');
});
});
$('#nearestparent').on('click', '#reportBtn', function() {...});