Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
$(document).delegate('[data-action="scroll"]', 'click', function() {
var scrollToId = $(this).attr('href').split('#')[1];
if (document.getElementById(scrollToId)){
$.scrollTo('#' + scrollToId, {
duration: 800,
onAfter: function(){ window.location.hash = '#' + scrollToId; }
return false;
$(document).delegate('[data-action="print"]', 'click', function() {
<a href="faq#question-1" data-action="scroll">Question 1</a>
<a href="faq#question-2" data-action="scroll">Question 2</a>
<button data-action="print">Print</button>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment