Home >>jQuery Tutorial >jQuery blur() Events
The blur() Events in jQuery is used to trigger the blur event, or to attach a function to run when a blur event occurs and it occurs when an element loses focus.
Syntax:Trigger the blur event for the selected elements: | $(selector).blur() |
Attach a function to the blur event: | $(selector).blur(function) |
Parameter | Description |
---|---|
function | It is Optional parameter and is used to specifies the function to run when the blur event occurs |
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("input").blur(function(){
alert("This input field has lost its focus.");
});
});
</script>
</head>
<body>
Enter your Fname: <input type="text">
<p>Write your words in the input field, and then click outside the field for blur.</p>
</body>
</html>
Write your words in the input field, and then click outside the field for blur.