Change the background color of the <div> element of the following code on clicking the button using jquery

  • جي كويري

Change the background color of the <div> element of the following code on clicking the button 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>JS Bin</title>
</head>
<body>
 <div style="background-color:yellow">
   <p>Click the button to change the background color of this paragraph.</p>
 <button>Click me!</button>
</div>
</body>
</html>

JavaScript Code:

$("div").on( "click", "button", function( event ) {
  $(event.delegateTarget ).css( "background-color", "green");
});
هل كان المحتوى مفيد؟

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

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

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