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

  • جي كويري

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

الأجوبة

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

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

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

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