jQuery blur() trigger blur event

Description

jQuery blur() trigger blur event

View in separate window



<!DOCTYPE html>
<html>
<head>
<script 
 src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js">
</script>//from www . j  av  a 2 s .  c  o  m
<script>
$(document).ready(function(){
  $("#btn1").click(function(){
    $("input").focus();
    $("p").html("focus event triggered");
  });
  $("#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>



PreviousNext

Related