How to remove focus from submit button
How can I remove focus from submit button? I don't know why 开发者_Python百科it is there in the first plate, and it looks really ugly here is a screenshot :
And here is how it should look like, it regains its appearance after I click beside it and hover it.
This worked :
var selectedInput = null;
$(document).ready(function() {
$('input, textarea, select').focus(function() {
this.blur();
});
});
Try this in your button's CSS, or that of the enclosing <a>
(whatever has focus) if that's what you are using in the markup (reference):
outline:0 none;
Bear in mind that a distinct focus style is a valuable accessibility/usability feature, so you should provide some alternate focus hint that is more visually pleasing to you, rather than removing it completely.
In your body or form...
<form onready="document.getElementById('submit').blur();">
...
<input type="submit" id="submit" />
</form>
The first submit button in a form is always "in focus", hence, when you hit enter, your form gets submitted.
See responses to a similar post: Stopping IE from highlighting the first submit-button in a form
You can code your button as:
<button onClick='this.form.submit()'>Button Text</button>
That removes the "submit" functionality to code and thus the focus problem.
精彩评论