Focus cursor to a submit button
I have a standard form for a user login.
When I input the username and password, then press enter it gives the search result. The search text box is in the same page.
I want to set the focus on the submit button. The enter key issue only exists in IE? W开发者_StackOverflow中文版hat can I do to solve this problem?
You can focus anything with the focus() javascript method. This has nothing to do with PHP.
document.getElementById('ID_Name_Of_Your_Button').focus();
Submit button must be defined in the same form tag as the other form elements. And submit will be fired on what form you are focused while pressing [enter].
You don't need to focus any submit buttons in your case.
And the document content is needed for the more exact answer of course.
精彩评论