jQuery focus() Method

By: Bipin C Mathew 7 months, 1 week ago

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="https://code.jquery.com/jquery-1.10.2.js"> 

	<!-- 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"); 




Let us talk!

We take the vision which comes from dreams and apply the magic of science and mathematics, adding the heritage of our profession and our knowledge to create a design.