Alex Rivera | Logout

Is it possible to remove the focus from a text input when a page loads?

Asked 2010-11-25T11:54:22.963
89

I have a site with one textfield for search however I dont want the focus to be on it when the page loads however it is the only text input on the form, is it possible to remove the focus?

Edit
Report

2 Answers

97

use document.activeElement.blur();

example at http://jsfiddle.net/vGGdV/5/ that shows the currently focused element as well.

Keep a note though that calling blur() on the body element in IE will make the IE lose focus

answered 2010-11-25T12:10:58.803
9
$(function() {
 $("#MyTextBox").blur();
});
answered 2010-11-25T12:04:08.760

Your Answer