I’m trying to get the user’s cursor to automatically insert into the ‘Company name’ textbox without them having to do it. The result I’m seeing is that the cursor isn’t in there. Any idea?
but the behavior I’m seeing is that while the screen is scrolling, I see the blinking cursor in the <input id="#happitext"> textbox until the scrolling stops. When the scrolling stops, the cursor is no longer there.
After the scrolling has completed, you’re explicitly .focus()ing the scroll target, thus taking away the focus from the input element. It’s this line:
jQuerytarget.focus();
I suppose the purpose is that it allows you to immediately navigate to the next focusable element with the tab-key then – which is certainly a nice touch! If you don’t want that for specific elements, you might set a data-* attribute on the link (say data-prevent-focus), and check for that attribute at the top of the animation-complete callback. Along the lines of
// If the attribute is present, return from the function
if (event.target.dataset.preventFocus !== undefined) {
return
}
// Otherwise proceed as usual
// ...