jQuery:更改突出显示淡入淡出颜色?

是否有可能将jQuery高亮效果淡化的颜色更改为?

现在它以黄色开始突出显示,然后淡化为白色然后淡出。

我最终用黄色突出显示背景颜色,然后淡化为透明。

我刚刚在jQuery UI 1.8.9中遇到过这种行为,它似乎是一个bug。

围绕它的方法是定义我在CSS中突出显示的元素的背景颜色,而不是让它默认为透明。

如果未设置背景颜色(即它是透明的),假设您没有更改高亮颜色,那么它会将元素淡化为黄色然后变为白色然后淡出。

但是,如果设置要突出显示的元素的背景颜色,则在突出显示该元素时,它将淡化为黄色,然后淡化为元素的原始颜色。

$("#id").effect( "highlight",{color:'#FFFF00',easing:'easeInElastic'},4000 ); 

在效果的选项对象中,您可以将颜色的默认属性更改为您想要的任何颜色。 我的元素没有设置为颜色,它突出显示亮黄色,然后逐渐消失。 我正在使用jQuery 1.8.1和jQuery-UI。

下面是jQuery UI 1.8.9中的高亮效果源代码。 它看起来不应该淡化为白色……它应该从黄色(#ffff99或传入的颜色选项)淡化为原始背景颜色,该背景颜色缓存在变量animation 。 你使用的是1.8.9吗?

 /* * jQuery UI Effects Highlight 1.8.9 * * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Effects/Highlight * * Depends: * jquery.effects.core.js */ (function( $, undefined ) { $.effects.highlight = function(o) { return this.queue(function() { var elem = $(this), props = ['backgroundImage', 'backgroundColor', 'opacity'], mode = $.effects.setMode(elem, o.options.mode || 'show'), animation = { backgroundColor: elem.css('backgroundColor') }; if (mode == 'hide') { animation.opacity = 0; } $.effects.save(elem, props); elem .show() .css({ backgroundImage: 'none', backgroundColor: o.options.color || '#ffff99' }) .animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() { (mode == 'hide' && elem.hide()); $.effects.restore(elem, props); (mode == 'show' && !$.support.opacity && this.style.removeAttribute('filter')); (o.callback && o.callback.apply(this, arguments)); elem.dequeue(); } }); }); }; 

使用jQuery Color插件: https : //github.com/jquery/jquery-color

有了它,你可以突出显示元素并正确地淡化回透明。