Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery don't (or remove) focus on any form field [duplicate]

Possible Duplicate:
Jquery Unfocus

Have a form with just one password field tag, and as I use palceholder, I don't want to have automatic input focus. How can I set no focus at all within jquery?

Thanks, Markus

like image 812
Markus Avatar asked Jun 28 '11 10:06

Markus


2 Answers

I'm not fully clear on what you need, but I think you're looking for something like this:

$("input").blur();

That will remove the focus from any input element that may have it.

like image 117
James Allardice Avatar answered Oct 25 '22 14:10

James Allardice


You can disable the field. $('input.my-input').attr('disabled', true); Then re-enable it when you want to allow input (on click or whatever). You'd have to use some CSS (.my-input:disabled { ... }) to make sure the browser doesn't grey it out.

like image 41
Nathan MacInnes Avatar answered Oct 25 '22 14:10

Nathan MacInnes