The focus is a Jquery Event Method is used to focus on an element. The element get focused by mouse click or by "tab-navigating" to it. The focus method is often used in combination with the blur() method.


$(selector).focus() -Trigger the focus event for selected elements.

$(selector).focus(function) -Attach a function to the focus event.

Parameter: It accepts an optional parameter “function” which specifies the function to run when the focus event occurs.



		span { 
			display: none; 
		body { 
			width: 35%; 
			height: 50px; 
			border: 2px solid green; 
			padding: 35px; 
			margin: 10px; 
	<script src=""> 

	<!-- this paragraph element get focused -->
		<input type="text"> <span>focused</span></p> 

	<!-- jQuery code to show working of this method -->
		$("input").focus(function() { 
			$(this).next("span").css("display", "inline");