jquery-swapimage -- need to add fadein/out?

Soldato
Joined
20 Oct 2002
Posts
19,040
Location
London
So i'm trying to bodge yet another jQuery script, sorry :(

I've found swapimage which is great for simple rollovers, but what I'd really like to do is have the images fade in and out. It seems others have asked for this too, so I found this:

Code:
$.swapImage._swap = function(obj) {
            var id = $.data(this);
            var data = $.swapImage.data[id];
            if (typeof data.src != "undefined") {
                 var tmp = data.src;
                 data.src = this.src;
                 //this.src = tmp;
                 var o = this;
                 $(this).fadeTo("slow", 0.0001, function() {
                        o.src = tmp;
                        $(o).fadeTo("slow", 1);
                 });
            }
        };

But haven't really got much of a clue where to add it in the script :confused:

Can anyone help? Pretty please? :)
 
you could add that in an external javascript file and link to it or you could just put it in script tags at the top of your html file you want to use it with.

You dont put that in the actual jquery plugin file usually.
 
Back
Top Bottom