Q:

Attach a function to the focus event. The focus event occurs (display a message regarding the text field

0

Attach a function to the focus event. The focus event occurs (display a message regarding the text field) when the <input> field gets focus using jquery

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

HTML Code :

<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
  <meta charset="utf-8">
  <title>Attach a function to the focus event</title>
</head>
<body>
<p><input type="text"> <span>Input your first name</span></p>
<p><input type="text"> <span>Input your last name</span></p>
</body>
</html>

JavaScript Code :

$( "input" ).focus(function() {
  $( this ).next( "span" ).css( "display", "inline" ).fadeOut(5000);
});

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now