【发布时间】:2025-12-15 06:50:01
【问题描述】:
我有contextMenu 的这段代码,当删除行时会为行的颜色设置动画,但是当我将mouseout 和mouseover 部分添加到代码中时,已删除行的颜色不再改变:
$(function () {
$('.users').contextMenu({
selector: 'tr',
callback: function (key, options) {
if (key == 'delete') {
if (confirm(" Are you sure?")) {
$.post("../Actions/Delete.ashx", { type: "user", id: $(this).attr('id') });
$(this).animate({ backgroundColor: '#FF80FF' }, 1000);
}
}
},
items: {
"edit": { name: "edit" },
"delete": { name: "delete" }
}
});
//newly added part
$('tr').mouseover(function () {
$('td', this).animate
({ backgroundColor: "#80FF00" }, 300);
});
$('tr').mouseout(function () {
$('td', this).animate
({ backgroundColor: "white" }, 300);
});
//till here
});
删除确认后我在控制台中看到此错误:
[13:08:10.282] 找不到元素@localhost:1299/Actions/Delete.ashx:1
我哪里错了?
【问题讨论】:
-
@Pete 我的鼠标悬停在动画上做动画,但在
confirm动画之后不会改变颜色。所以我认为这不是重复的。
标签: jquery jquery-plugins jquery-animate mouseevent background-color