jQuery focus on element

30.Jun.2010

You can use jQuery focus on element in order to set focus upon element or in order to check if there is focus on element?

In order to set focus on element use:

1
jQuery('#element_id').focus();

In order to check if there is focus on element use:

1
2
3
if(jQuery('#element_id').is(":focus")) { //fixed thanks to [jquery programmer]
	alert('There is focus on element!');
} else alert('There is no focus on element...');