:header
selectorThe :header
selector selects all heading elements like h1,h2...h6.
:header
selector Syntax$(':header')
selector | description |
---|---|
$(':header') |
selects all the headers |
$('h1') |
selects all h1 headers |
$('h2') |
selects all h2 headers |
:header
selector ExamplesFollowing is a simple example which makes use of header selector.
This would select all the headers and add a background color to them.
<h1>Header 1</h1> <p>contents</p> <h2>Header 2</h2> <p>contents</p> <h3>Header 3</h3> <p>contents</p> <script> $(":header").css("background",'coral'); </script>
Only hightlight the header 2
<h1>Header 1</h1> <p>contents</p> <h2>Header 2</h2> <p>contents</p> <h3>Header 3</h3> <p>contents</p> <script> $("h2").css("background",'coral'); </script>