我試圖做一個「更多」10個新聞主題的帖子後。jQuery:問題與功能附加文字
對於這些新聞主題,有一些功能,你可以點擊評論,然後出現和你評論,而無需轉到另一個頁面(AJAX調用)和其他一些這樣的。這在前10個帖子中工作正常。
現在,當您在這10個新聞主題的底部點擊更多,您將獲得10個其他人。此處使用Ajax調用,並在第一個10之後附加。 這工作得很好。
但是不工作(我的問題是,那些點擊功能我:
$('.reply').click(function() {
$('#replyWall'+$(this).attr('data-id')).toggle();
document.getElementById('replyMsg'+$(this).attr('data-id')).focus();
});
$('.writeSComment').click(function() {
$(this).hide();
$('#replyToSComment'+$(this).attr('data-id')).toggle();
document.getElementById('commentStatus'+$(this).attr('data-id')).focus();
});
不行的也許就是這一點,因爲附加的網站加載之後來臨的時候,因爲你第一次。點擊「更多」,所以它找不到任何與該ID有此事件點擊
但在這附加,有這些id's,和所有,所以有什麼辦法來獲得這些功能與附加的東西一起工作,或者我該怎麼做?
$('.more').live("click",function() {
var ID = $(this).attr("id");
if(ID) {
$("#more"+ID).html('<img src="moreajax.gif" />');
$.ajax({
type: "POST",
url: "misc/moreactivities.php",
data: "lastmsg="+ ID,
cache: false,
success: function(html) {
$("#profileWall").append(html);
$("#more"+ID).remove();
}
});
}
});
這裏沒有代碼,做任何追加。你爲什麼將jQuery和getElementById混合? – 2010-10-24 15:33:25
對不起更新的問題。 – Johnson 2010-10-24 15:35:57