Please consider the following code:
//Focus on the field on page load.
$("#user_login").focus();
//Remove prompt after a couple of seconds.
window.setTimeout(function() {
$("#user_login").blur();},
3000);
I have several tooltips and other events tied to #user_login input on focus. But not to annoy user, I want to remove focus after a couple of seconds.
This is a way I’m doing right now – as I can understand delay() won’t work in this instance. Is there any other pure jquery way to do this? Something along the lines of:
$("#user_login").focus().delay(3000).blur();
Thanks
P.S.:
My solution works fine right now as it is, this more for educational purposes.
delay()only works with animations.Make a plugin:
Use the plugin:
Here’s a silly demo: http://jsfiddle.net/AlienWebguy/gKECa/