blur() Method - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:blur

Description

The blur() method triggers the blur event, or sets a function as blur event handler.

Syntax

$(selector).blur(function);
Parameter Require Description
function Optional.function to run when the blur event occurs

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("input").blur(function(){
        console.log("This input field has lost its focus.");
    });// w w w.  j  ava 2  s . c  o  m
});
</script>
</head>
<body>

Enter your name: <input type="text">
<p>Write something in the input field, and then click outside the field to lose focus (blur).</p>

</body>
</html>

Related Tutorials