dinbror / blazy

Hey, be lazy! bLazy.JS is a lightweight pure JavaScript script for lazy loading and multi-serving images. It's working in all modern browsers including IE7+.
http://dinbror.dk/blazy
MIT License
2.63k stars 356 forks source link

Changing a success element #130

Closed wassereimer86 closed 7 years ago

wassereimer86 commented 7 years ago

I want to add a class to an image if it has a specific class in a callback function. After adding the class the other should be removed.

http://dinbror.dk/blog/blazy/#Callback

;(function() {
    var bLazy = new Blazy({
    success: function(ele){
        if $(ele).hasClass("gojarallax") {
            $(ele).addClass("jarallax");
            $(ele).removeClass("gojarallax");
            $('.jarallax').jarallax();
        }
    },
    src: 'data-blazy',
    });
})();

This is what i have. But it don´t work. I get the error:

Uncaught SyntaxError: Unexpected identifier

What am i doing wrong?

wassereimer86 commented 7 years ago

Oh man..... After hours.... So stupid.....

            if ($(ele).hasClass("gojarallax")) {
                 $(ele).addClass("jarallax");
                     $(ele).removeClass("gojarallax");
                     $('.jarallax').jarallax();
            }