0

Is there a way in jquery or javascript to detect when then opacity of an element changes then launch a function to add new effects like for example if you had a page where automatic things happen like an element faded in then you wanted to launch something else when that happened. How would you do this???

It is kind of like a slide show.

Here is a demo of what I have so far:

http://jsfiddle.net/Hive7/n57Zy/

Than I want when the last elements opacity changes then start the loop again

Thanks in advance

4

2 回答 2

3

这是一个示例,如何使用 javascript 检测 CSS 中的更改选择器值。

我的解决方案受到http://darcyclarke.me/dev/watch/的启发,使用jquery.watch.js

jQuery(function($){
    $("div").watch('opacity', function(){
        alert("OMG!");
    });
});

JSFiddle:http: //jsfiddle.net/KWqUv/1/

于 2013-07-27T13:45:19.790 回答
1

我正在谈论的一个例子,给你的想法。

var delayOL = d;
var fadeLoop = (function fadeLoop(i) {
    $('.slideshow img').eq(i).delay(delayOL).fadeOut(d, function () {
        i++;
        if (i === $('.slideshow').find('img').length) i = 0;
        $('.slideshow img').eq(i).fadeIn(d, function () {
            delayOL = 0;
            setTimeout(function () {
                fadeLoop(i)
            }, g);
        });
    });
})(0);

演示

于 2013-07-27T13:18:57.220 回答