我在這裏有兩個html。第一個是由php動態生成的,第二個只是html測試。無法刪除使用jquery動態創建的列表
我也有以下的jquery。
當我點擊第二個類中的類刪除(純html)時,它很好地工作。但是,當我點擊第一個中的十字架時,它不起作用。 它最終將#重定向到主頁。
我希望有人指出我做錯了什麼。
提前致謝。
HTML
First part (dyanmicall generated)
<ul style="display: block;" id="message">
<li class="41">
<span class="user"><strong>shin</strong></span>
<span class="msg"> delete this as well</span>
<span class="date">2010-01-15 07:47:31</span>
<a href="#" id="41" class="delete">x</a>
<div class="clear"></div></li>
<li class="40">
<span class="user"><strong>shin</strong></span>
<span class="msg"> delete me as well</span>
<span class="date">2010-01-14 16:01:44</span>
<a href="#" id="40" class="delete">x</a>
<div class="clear"></div></li>
...
...</ul>
Second part which is plain html
<ul id="another">
<li><a href="#">you can't delete me</a></li>
<li><a href="#" class="delete">delete this</a></li>
<li><a href="#" class="delete">delete this</a></li>
</ul>
這裏是jQuery的
$(".delete").click(function(event) {
event.preventDefault();
loading.fadeIn();
var commentContainer = $(this).parent();
var id = $(this).attr("id");
// var string = 'id='+ id ;
$.ajax({
type: "POST",
url: "index.php/admin/messages/changestatus/"+id,
// data: string,
cache: false,
success: function(){
commentContainer.slideUp('slow', function() {$(this).remove();});
loading.fadeOut();
}
});
return false;
});
我使用笨的方式。
它不會引發任何錯誤。看起來,我在codeigniter中的其他代碼是不正確的。謝謝你的幫助。 – shin 2010-01-15 07:39:09