Jquery 如何使用淡出效果更改表格行的背景色?
从表中删除行时,我想将行的背景色更改为红色 这是我目前的代码:Jquery 如何使用淡出效果更改表格行的背景色?,jquery,css,Jquery,Css,从表中删除行时,我想将行的背景色更改为红色 这是我目前的代码: $('.delete').click(function(){ $id=$(this).attr('id'); $row = $(this).parents('tr:first'); $.ajax({ url:'admin/delete_post', dataType:'json', type:'POST', data:'id=' + $id,
$('.delete').click(function(){
$id=$(this).attr('id');
$row = $(this).parents('tr:first');
$.ajax({
url:'admin/delete_post',
dataType:'json',
type:'POST',
data:'id=' + $id,
error:function(){
alert('There was an error');
},
success:function(data){
$row.fadeOut(600,function(){
$(this).remove();
});
}
})
});
编辑:包含标记。
<tr>
<td>abc</td>
<td>
<div class="controls ">
<textarea class="input-xlarge span10" name="content" id="textarea" rows="5"
cols="45">text</textarea>
</div></td>
<td>
<a class="btn delete" id="58"><i class="icon-trash"></i> Delete</a>
<a class="btn save" ><i class="icon-ok"></i> Save</a>
</td>
</tr>
abc
文本
删除
拯救
在你的帖子中没有唱$this
,我认为应该唱this
$row.css('background', 'red')
.fadeOut(600,function(){
$(this).remove();
});
$this
变量代表什么?我尝试了这个,但没有成功。我已经包括了html,以防这会改变答案。这很有效。你能解释一下为什么其他代码没有?谢谢。有一段时间我忘记了在tr
元素上应用背景色对几个浏览器没有影响
success:function(data){
$row.find('td').css('backgroundColor', 'red').end().fadeOut(600,function(){
...
});
}