Andy Holmes
Andy Holmes

Reputation: 8077

Trigger jquery animations based on url

I'd like to be able to trigger animations based on the websites requested url. So for example www.site.com/index.php#houses

Then that would make a <div id="houses"> fade in?

Is there a simple way to do this?

Upvotes: 0

Views: 90

Answers (2)

A. Wolff
A. Wolff

Reputation: 74420

You could try this:

$(function(){
    $(window.location.hash).fadeIn();
});

Upvotes: 4

Jaiwo99
Jaiwo99

Reputation: 10017

try this:

function(){
    var uri = window.location.pathname;
    if(uri.indexOf("#houses") > 0){
        $("#houses").fadeIn();
    }
}

Upvotes: 1

Related Questions