jQuery focus event

jQuery focus event example for COMP1021

by scsswil

HTML

<p>Click on the field, then not on the field.</p>
<div style="border: 1px solid black;padding:10px;">
Enter your name:
  <input type="text">
</div>

JavaScript

$(document).ready(function() {
  $("div").focusin(function() {
    $(this).css("background-color", "#12ee34");
  });
  $("div").focusout(function() {
    $(this).css("background-color", "#FFFFFF");
  });
});