jQuery – :header Selector

The jQuery header selector selects all header elements (h1 to h6):

Source Code

<!DOCTYPE html>
<html>
<head>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<div class="div1">
<h1>Text 1</h1>
<h5>Text 2</h5>
</div>
<button>Click Here</button>

  
<script>
jQuery("button").click(function () {
	jQuery(".div1 > :header").css({border:"3px #1E8CBE solid"});
});
</script>
</body>
</html>

Demo

Following example finds all the headers (inside div1 class) on the page and creates a border.

Text 1

Text 2

,

No comments yet.

Leave a Reply