Attach a function to the blur event using jquery

  • جي كويري

Attach a function to the blur event. The blur event occurs when the following <input> Field1 loses focus. using jquery

الأجوبة

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" );
});
هل كان المحتوى مفيد؟

معلومات ذات صلة

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...