我有以下脚本来淡化然后删除一个表行,但它只删除该行。
function deleteconfirmation() {
$(this).fadeOut('slow', function () { $(this).remove(); });
jAlert('The Answer was deleted succsfully', 'Deletion Confirmation');
}
那么在删除之前可以淡出表格行吗?如果是,我该怎么做?
编辑: - 这是删除其行的表: -
@foreach (var answer in Model.Answers.OrderBy(a=> a.IsRight))
{
<tr id = @answer.AnswersID>
<td>
@Html.DisplayFor(modelItem => answer.Description)
</td>
<td>
@Html.DisplayFor(modelItem => answer.Answer_Description.description)
</td>
<td>
@Ajax.ActionLink("Delete", "Delete", "Answer",
new { id = answer.AnswersID },
new AjaxOptions
{
//OnBegin = "deleteconfirmation1",
Confirm = "Are You sure You want to delete this Answer ?",
HttpMethod = "Post",
UpdateTargetId = @answer.AnswersID.ToString(),
OnSuccess = "deleteconfirmation",
OnFailure = "deletionerror"
})
</td>
</tr>
}
答案 0 :(得分:0)
试试这个:
$( '.mySelector' ).click( function(){
var self = this;
/* look the next line */
$( self ).fadeOut('slow',function(){
$( this ).remove();
});
} );
第一: “$(this)”是一个对象?
尝试:
if( $(this).length > 0 )
{
alert( 'Yes!' );
}else{
alert( 'No!' );
}
如果不是对象,请定义对象:
var self = this;
//OR
var self = $( '.mtSelector' );