jQuery focus event

jQuery focus event example for COMP1021

by scsswil

HTML

<p>Click on the field.</p>
<input type="text"><span style="display:none;">The field got focus.</span>

JavaScript

$(document).ready(function() {
  $("input").focus(function() {
    $("span").css("display", "inline").fadeOut(1000);
  });
});