bamabacho
bamabacho

Reputation: 321

Jquery code not working in Firefox simple click events

Code works in IE and Chrome, not Firefox. No error messagein Firebug, just page reload. And the gallery code and the fadeIn at the beginning work as well, just the subsequent click event:

$(document).ready(function(){
     $('.gallery').slick({
        adaptiveHeight:true,
        dots:true,
        arrows:true,
        autoplay:true,
        infinite:true,
});
$("h1").fadeIn(1000, function(){
    $("h2").fadeIn(1000, function(){
        $("h3").fadeIn(1000);
    });
});
$("#about").click(function() {
        event.preventDefault();
        $('html, body').animate({
            scrollTop: $("#aboutContainer").offset().top
        }, 1000);
});

Is it to do with passing the $('#aboutContainer).offset.top?

Upvotes: 0

Views: 47

Answers (1)

Jovan Perovic
Jovan Perovic

Reputation: 20201

I think your event variable is not being defined. You need to specify it as a closure argument:

$("#about").click(function(event) { // <<--- THIS
        event.preventDefault();
        $('html, body').animate({
            scrollTop: $("#aboutContainer").offset().top
        }, 1000);
});

Edit:

Another thing, you didn't say if you are executing this on page load complete or not. The #about element might not be available at the time of execution.

Upvotes: 2

Related Questions