Friday, April 20, 2012

(Solved) Jquery, activate a script when a hash is in url

So I have some images that are positioned absolutely above a page set to hidden that display inherit when you click on the appropriate link triggering the event that displays them.



Now, here's where my question comes in. Say I assign an image an ID of "example" - is there any way that when someone enters the site with a hash tag #example or clicks on a link with the hash tag #example in the url, that the event would trigger for an image with the same ID? I'm really stumped on this one



What I had been using is this:



$("#activate1").click(function () {
$("#flyer1").css("display", "inherit");


});



Which worked fine but now I'll have to add flyers each week which would mean I need to change that unless I want to write the above code for each unique case. But on top of that, I also now have to send them to people through a link so the script now has to trigger when they click the link - I figured the best way to tackle this would probably be implementing a hash tag trigger





No comments:

Post a Comment