Call a function on an anchored object


/ Published in: jQuery
Save to your folder(s)

Sometimes you click a link like faq.html#item5 and, after the browser jumps you to the anchor, you have trouble spotting the item you're looking for. anchorAway is a little function that helps you call a function on anchored items, maybe something like a scrollTo or a background color, that helps users easily spot the content you directed them to.

anchorAway parses the window.location for an anchor (#foo), finds it, and calls the function (act(bar)) on it. It also finds any on-page links to the objects you've specified and binds the same function to their click event.

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.