I’m trying to get jQuery to take the hashtag from a URL and do some functions with it:
Hashtag example:
http://www.example.com/Help.asp#contact
I built out a help center. This help center hides all the answers on the page load and when you click on a question, the answer slides down. Each question is it’s own anchor with a name identifier. So when you go to http://www.example.com/Help.asp#contact, the document automatically scrolls down to <a name="contact">. We use these a lot in emails or whatever when we want to direct a user straight to the question they’re asking in the Help Center. However, it would be even easier to use, if that anchor is triggered a second after the page loads. What I’m guessing is, I’d need to grab the hashtag, and have a jQuery script like this:
$(document).ready(function(){
$('a[name="~~HASHTAG~~"]').trigger('click').delay(1000);
});
How can I get the hashtag from the URL? Thanks for your help.
Here’s my HTML http://jsfiddle.net/tBLuL/
Try this.
The delay of 1 sec after the click is useless. What are you trying to achieve with delay?
Update:
If you want to delay the
clicktry this.