0
function showText(text) {
    $("#messages").append(text + "</br>");
    $("#messages").scrollTop($("#messages")[0].scrollHeight); 
    //line above is to automatically scroll the div to last added text
}

我想要添加线条的背景,淡入然后淡出(它应该在半秒或类似的时间后淡出,只是为了引起用户的注意)。我不知道如何使用css。如果可能的话,淡入淡出的颜色应该是灯泡黄色,就好像它被突出显示一样:P 在此先感谢 :)

4

1 回答 1

1

我找到了您正在寻找的确切内容:

http://jsfiddle.net/BradleyStaples/G2tqd/

$.fn.bgColorFade = function(userOptions) {
// starting color, ending color, duration in ms
var options = $.extend({
    start: "yellow",
    end: "#fff",
    time: 500
}, userOptions || {});
$(this).css({
    backgroundColor: options.start
}).animate({
    backgroundColor: options.end
}, options.time);
return this;
};

$(".test").bgColorFade({
  time: 500
});

然后将其反转以使其淡出。

于 2013-06-24T14:03:37.010 回答