The blur() is an inbuilt method is jQuery that is used to remove focus from the selected element. This method start the blur event or it can be attached a function to run when a blur event occurs.
Syntax:
$(selector).blur(function)
Parameter: It accepts an optional parameter “function”.
Return Value: It does not return anything, it simply trigger the blur event on the selected element.
Code #1:
In the below code, no function is passed to the blur method.
<html> <head> jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function() { $("#btn").click(function() { $("input").blur(); $("p").html("This is blur method that is used!!!"); }); }); </script> </head> <body> <!--enter value and click on the button --> Enter Value: <input type="text"> <br> <br> <button id="btn">start blur event!!!</button> <p style="color:green"></p> </body> </html> |
Output:
Before entering any value to the “Enter Value” box-

After entering a value of “GeeksforGeeks” to the “Enter Value” box-

After clicking the “start blur event” button-

Code #2:
In the below code, function is passed to the blur method.
<html> <head> jquery/3.3.1/jquery.min.js"></script> <script> <!-- jQuery code to show blur method --> $(document).ready(function() { $("input").blur(function() { $(this).css("background-color", "#ADFF2F"); }); }); </script> </head> <body> <!-- Enter a value to the field and click outside to see the change --> Enter Value: <input type="text" name="fullname"> </body> </html> |
Output:
Before entering any value to the “Enter Value” box-
![]()
After entering a value of “GeeksforGeeks” to the “Enter Value” box-

After clicking the mouse button anywhere on the screen-
![]()
Recommended Posts:
- Javascript | Window Blur() and Window Focus() Method
- jQuery | jQuery.fx.interval Property with example
- jQuery | jQuery.fx.off Property
- jQuery | jQuery.support Property
- jQuery | jquery Property
- jQuery | prepend() with Examples
- jQuery | dblclick() with Examples
- jQuery | offset() with Examples
- jQuery | children() with Examples
- jQuery | Hide/Show, Toggle and Fading methods with Examples
- jQuery | focusin() with Examples
- jQuery | Animation, Slide methods with Examples
- jQuery | change() with Examples
- jQuery | filter() with Examples
- jQuery | height() and innerHeight() with Examples
- jQuery | eq() with Examples
- jQuery | empty() with Examples
- jQuery | not() method with Examples
- jQuery | first() with Examples
- jQuery | parent() & parents() with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


