Find all h1 elements that are children of a div element and apply a background to them using jquery

  • جي كويري

Find all h1 elements that are children of a div element and apply a background to them 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>Find all h1 elements that are children of a div element and apply a background to them</title>
</head>
<body>
<h1>abc</h1>
<div>
  <h1>div-1</h1>
  <h1>div-2</h1>
 </div>
  <h1>xyz</h1>
  </body>
</html>

JavaScript Code :

$( "div > h1" ).css("background", "#0686c9");
هل كان المحتوى مفيد؟

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

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

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