我需要保留点击的div的颜色,直到同一类的另一个div被点击。现在,我有这样的代码:禁用鼠标事件点击为(this)并重新启用它们('.class')。not(this) - jquery
$('.aaa').mouseenter(function() {
$(this).css('background', '#dddddd');
});
$('.aaa').mouseleave(function() {
$(this).css('background', '#888888');
});
$('.aaa').click(function() {
$(this).css('background', '#555555');
$('.aaa').not(this).css('background', '#111111');
$(this).off('mouseenter mouseleave');
$('.aaa').not(this).on('mouseenter mouseleave');
});
这里唯一的问题是,我不能重新启用以前禁用的事件(以前单击元素)。
这是如何实现的?
简单,实用,工程进展顺利。谢谢:) – weaponx
@weaponx虽然这回答了关于禁用和启用鼠标输入的orinigal问题,但您尝试使用简单CSS实现的操作会简单得多。 –