我在这里有两个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