我有一个代码片段,它运行一个 ajax 请求到另一个脚本,并<li>
在每次单击更多按钮时附加新的 s。
我正在使用以下代码:
$(function(){
$('.more').on("click",function(){
var ID = $(this).attr("id");
if(ID){
$("#more"+ID).html('<img src="moreajax.gif" />');
$.ajax({
type: "POST",
url: "/cs_directory/helpers/jpost_load_post.php",
data: "lastmsg="+ ID,
cache: false,
success: function(html){
$("ul#existing_campaign").append(html);
$("#more"+ID).remove(); // removing old more button
}
});
}else{
$(".morebox").html('The End');// no results
}
return false;
});
});
我正在添加#more 按钮以及来自我的网址的返回。
但是,因为它是在加载文档后附加的。我的功能似乎不再适用了。我该如何更改它,以便每次单击它时,更多按钮都会递归地起作用?