jQuery代码:jQuery的鼠标悬停改变背景颜色
$(".menu_clickable").mouseover(function() {
$(this).css({'background-color' : '#F00'}).mouseout(function(){
$(this).css({'background-color' : '#FFF'});
});
});
$(".menu_clickable").live('click', function() {
$(this).css({'background-color' : '#FCC'});
});
HTML源代码:
<div class="menu_clickable prof_info2" id="prof_info" >first</div>
<div class="menu_clickable prof_info3" id="prof_info" >second</div>
<div class="menu_clickable prof_info3" id="prof_info" >third</div>
我试图使用jQuery做悬停效应和它工作正常,但如果我想改变DIV背景颜色当它被点击时它不起作用,实际上点击的DIV会改变背景颜色,但当光标放在它上面时它会保持原样。如果将其移出,它将恢复原始背景颜色。为什么?
如何停止clicked DIV上的鼠标悬停事件? – Sergio 2010-06-03 19:13:08
@Sergio - 您只需删除与其关联的功能,或者在鼠标点击DIV时使用不同的类/功能 – Sairam 2010-06-03 19:16:50