Have a function for scroll down to input and focus in it?


But not want to work? I want to scroll with offset.top and also focus in field?

Any idea?


Open the console. There’s an error in there.

For some reason, the jQuery in your fiddle is rejecting the on() call. Change it to $(...).click(function(event){...} ); and it should work fine. That, or simply switch to a newer version of jQuery in the selector dropdown. 3.x works nicely, tested it with your function as-is.

Thanks! Is scroll now but not focus?


Uncaught TypeError: asd.focus is not a function

Thanks for help!

Take a look at line six. In line four, you get to the element asd via $("#"+asd) - but line six is throwing an error. See the difference?

So not can be duplicated? Then how can still focus in it? I mean for asd is also scroll and focus? Need to set with a var the first value and then pass to focus?


All I was saying is, in the scrollTop: line, you use the jQuery wrapper on that asd element. In the focus line, however, you don’t.

Consider this, maybe - create a variable with the asd element wrapped in the jQuery object, then use that as a reference in both scrollTop and focus.


1 Like