Simple example of jquery implementation of input box getting focus

  • 2021-07-16 01:10:41
  • OfStack

Get a simple example of a form focus discoloration


//.login-form Form style class 
//.item input Input box parent div
// focus Is the style class to add 
    $(".login-form").on("focus", "input", function(){
      $(this).closest('.item').addClass('focus');
    }).on("blur","input",function(){
      $(this).closest('.item').removeClass('focus');
    });

// Initializes the selected user name input box 
$("#itemBox").find("input[name=username]").focus();



Related articles: