0

This question already has an answer here:

I`m trying to include a parallax Effect into one of my cutsom page templates. The js function is returning the following error in the firebug console:

TypeError: $ is not a function

The error is on the first line wich is:

var parallaxElements = $('.parallax'),

Any help would be appreciated. Here the full code:

    var parallaxElements = $('.parallax'),
        parallaxQuantity = parallaxElements.length;

    $(window).on('scroll', function () {

    window.requestAnimationFrame(function () {

    for (var i = 0; i < parallaxQuantity; i++) {
        var currentElement =  parallaxElements.eq(i);
        var scrolled = $(window).scrollTop();

        currentElement.css({
        'transform': 'translate3d(0,' + scrolled * -0.3 + 'px, 0)'
        });

    }
});

});

marked as duplicate by Howdy_McGee, fuxia May 11 '16 at 17:52

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

-1

Use jQuery instead of $. e.g use jQuery('.parallax') instead of $('.parallax').

  • I changed all the $ to jQuery and the errors are gone - but the effect dont work? codepen.io/taniarascia/pen/mPpZZM – NewUser May 11 '16 at 17:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.