Q:

Attach a function to the blur event using jquery

0

Attach a function to the blur event. The blur event occurs when the following <input> Field1 loses 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>jQuery: Attach a function to the blur event</title>
</head>
<body>
<form>
<input id="field1" type="text" value="Field 1">
<input id="field2" type="text" value="Field 2">
</form>
  <p>Write something in the input Field 1, and then click outside the field to check lose focus.</p>
</body>
</html>

JavaScript Code :

$( "#field1" ).blur(function() {
  alert( "Lose focus from Field1" );
});

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