我有一个下拉菜单,我使用mouseenter()
函数。如果鼠标进入我的选择器区域背景颜色返回到黄色。但是,如果我离开了选择器的区域,我想设置选择器区域的默认颜色,而不使用mouseleave()
函数。使用JQuery返回默认颜色
我该如何解决?
$(document).ready(function(){
$("#l_ev_men").mouseenter(function(){
$(this).css("background-color","yellow");
$(this).css("color","black");
});
$("#l_ev_men").mouseleave(function(){ // ı dont want to use this function
});
});
为什么你不希望使用鼠标离开? – j08691
您可以使用.hover()而不是鼠标输入/离开 - http://api.jquery.com/hover/ – Matt
为什么不使用CSS? – Ryan