I want to know if the line below is
needed in this script, and if so, what purpose it
Calling the jQuery
method with no arguments sets focus to the
specified element. That line is the first line
inside the document ready handler. So its purpose
is to set focus to that particular field when the
page first opens/loads.
As to whether it is needed, that's
really up to the page designer. Setting focus to
the field the user will most likely want to
interact with first is generally helpful to them.
If you didn't have that it wouldn't stop the page
from working or anything.
If I do not have a form field with id
"quantity-0" what other elements could I focus (if
You can set focus to whatever element you like.
Normally this would be either a form element of
some kind (input, button, etc.) or a hyperlink.
Whichever one makes most sense for a user to
interact with first upon page load.
Can I focus a hidden form
Why would you want to do that? It doesn't make
sense for a user to interact with a hidden
element. I believe attempting to set focus to a
hidden element may give an error in some