Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set focus on top of the page [duplicate]

Tags:

javascript

How do I set focus to the top of a page?

like image 565
vakas Avatar asked Jun 02 '10 10:06

vakas


People also ask

How do you put a focus on the top of the page?

Solution 1$('form'). on('submit', function() { $('html, body'). animate({scrollTop:0}, 'slow'); }); This way, your page gently eases to the top of your page when the form is submitted.

How do you shift focus in HTML?

To set focus to an HTML form element, the focus() method of JavaScript can be used. To do so, call this method on an object of the element that is to be focused, as shown in the example. Example 1: The focus() method is set to the input tag when user clicks on Focus button.

How do I make a div tab focusable?

You can make it focusable by adding a tabindex=0 attribute value to it. That will add the element to the list of elements that can be focused by pressing the Tab key, in the sequence of such elements as defined in the HTML document.


1 Answers

I found this use of the window.scrollTo function:

window.scrollTo(0,0);

like image 51
Gotter Avatar answered Oct 02 '22 09:10

Gotter