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

Shp*_*ord 8 jquery jquery-ui highlight jquery-effects

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

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

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

Ros*_*oss 5

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

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

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

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


Rww*_*wwL 0

下面是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();
                }
            });
    });
};
Run Code Online (Sandbox Code Playgroud)