I am trying to set focus to a text input box in document ready function this works great except the input box is in a fieldset about 50 px down the page so the page header is not visible when the input box get focus I tried to use $(window).scrollTop(0) which works but then the set focus code overrides the scrollTop code. The header elements are H1 text and a button with an ID then the fieldset with the input box I have seen numerous answers here but I do not like the idea of animate after everyone is loaded I have seen stopPropagation() but not sure how that works Is this a true false or on off command? the browser is IE 8 and above Perhaps I should have the end user work from the bottom UP ha ha
Asked
Active
Viewed 487 times
-1
-
1It would be a lot better if you could provide some code you're working with (e.g. a jsfiddle). Also better punctuate and reformat your question, so it become a bit more readable. – Sidney Gijzen Jun 15 '13 at 20:49
-
The project is rather large and the last time I added all the code someone was upset with me My Question is how to use focus and scrollTop in harmony as for JSfiddle not a big fan so I shy away from sites that want too much information – Vector Jun 15 '13 at 22:35
1 Answers
0
AS best I can tell if you have both .focus and .scrollTop(0) in the document ready function one fire then the other so the solution in this case was to move the focus code from the head to the body all by its lonesome as this $(":text")[0].focus(); I am not sure this is an elagant way to solve the issue but it works

Vector
- 3,066
- 5
- 27
- 54