Q:

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

1

Find all h1 elements that are children of a div element and apply a background to them 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>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");

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