我正在制作一个小脚本,在显示 10 个条目的最后一个显示更多按钮。这是代码
<div id="more<?=$lastid;?>">
<a onclick="showmore(<?=$lastid;?>);">More</a>
</div>
脚本是
function showmore(lastid) {
$.post("/ajax/showmore.php", {
lastid: lastid,
}, function(response) {
$("#more" + lastid).show();
setTimeout("finishAjax('more' + lastid, '" + escape(response) + "')", 300);
});
return false;
}
function finishAjax(a, b) {
$("#" + a).html(unescape(b));
$("#" + a).fadeIn(1e3)
}
但脚本不起作用?这里有什么问题 ?
我用恒定的 div id 测试了脚本,它运行良好,但是当我为 div 添加 $lastid 并在脚本端添加 $("#more" + lastid) 时,它不起作用
任何想法使 DIV ID 可变?
提前致谢