需要在两个背景之间添加淡入淡出效果

时间:2016-03-02 11:51:39

标签: javascript jquery css html5 background

我想为此jquery背景更改代码

添加淡入淡出效果
 var images = ['img1.jpg', 'img2.jpg'];
 var i = 0;

 setInterval(function(){
    $('body').css('background-image', function() {
            if (i >= images.length) {
                i=0;
            }
            return 'url(' + images[i++] + ')'; 
        });
 }, 5000);

1 个答案:

答案 0 :(得分:0)

您想要的结果无法使用当前的方法完成,我不确定是否可以使用addElement: function (x, y) { var self = this;// self is an alias for this var id = 'id_' + this.elements.length;// create unique ID var newElement = $('<div class="element"></div>'); newElement.css("top", y); newElement.css("left", x); newElement.attr('id', id);//add ID for element newElement.appendTo(this.area); this.elements.push( { id: id, x: x, y: y } ); newElement.dragabble({ stop: function () { var element_id = ui.helper.attr('id'); // ui.position or ui.offset try what you need self.updateElement(element_id, ui.position.top, ui.position.left); } }); }, CSS完成此操作。但是如果你使用两个适合身体的元素,为它们添加背景并相应淡化它们,你就可以做到。

相关问题