Trigger blur event - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:blur

Description

Trigger blur event

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(){
    $("#btn1").click(function(){
        $("input").focus();
        $("p").html("focus event triggered");
    });/*from  w w  w  . j av a  2s  .c  o  m*/
    $("#btn2").click(function(){
        $("input").blur();
        $("p").html("blur event triggered");
    });
});
</script>
</head>
<body>

Enter your name: <input type="text">
<br><br>

<button id="btn1">Trigger focus event</button>
<button id="btn2">Trigger blur event</button>

<p style="color:red"></p>

</body>
</html>

Related Tutorials