:header Selector - Javascript jQuery Selector

Javascript examples for jQuery Selector:header

Description

The :header selector selects all header elements, <h1> to <h6>.

The following code shows how to select all header elements, h1 to h6:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $(":header").css("background-color", "yellow");
});/*  w  w  w.j  a  v a2  s.  c  o  m*/
</script>
</head>
<body>

<h1>Welcome to My Homepage</h1>
<h2>My Homepage</h2>
<h3>It's amazing!</h3>

<p class="intro">This is a test.</p>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
<p>Who is your favourite:</p>

<ul id="choose">

  <li>A</li>
  <li>B<h2>My Homepage</h2></li>
  <li>C</li>
</ul>

</body>
</html>

Related Tutorials