Skip to content

Instantly share code, notes, and snippets.

@psdtohtml5
Created August 12, 2013 21:39
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save psdtohtml5/6215547 to your computer and use it in GitHub Desktop.
Save psdtohtml5/6215547 to your computer and use it in GitHub Desktop.
JavaScript : Scroll and Focus to Element (input)
var cursorFocus = function(elem) {
var x = window.scrollX, y = window.scrollY;
window.scrollTo(x, y);
elem.focus();
}
cursorFocus(document.getelementbyId('search-terms'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment