且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

jQuery设置为透明动画

更新时间:2023-10-27 20:34:52

不要更改背景颜色,而是删除该属性!

代码很简单:

$("li").hover(
    function(){
        $(this).toggleClass('hover', 1000);
    },
    function(){
        $(this).toggleClass('hover', 2000);
    }
);

示例: http://jsfiddle.net/rdWTE/

要使其正常工作,您需要jQuery和jQuery UI.确实满足您的要求(颜色除外)!

For it to work, you need jQuery and jQuery UI. Does exactly what you wanted (except the colors)!

jQuery脚本中的这些数字代表以毫秒为单位的动画持续时间.

Those numbers in jQuery script stand for animation duration in milliseconds.

嗯...发现toggleClass可能会不时地出错.***在悬停时使用addClass,在鼠标移出时使用removeClass.

Uhm... Found out that toggleClass can bug from time to time. Better to use addClass on hover, and removeClass on mouse out.