jQuery blur event

jQuery blur event example for COMP1021

by scsswil

HTML

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

JavaScript

$(document).ready(function() {
  $("input").blur(function() {
    alert("Hello " + $("#name").val());
  });
});