jQuery:Selector :header

:header

Overview

Match h1, h2, h3, such as the title element.

Demo

Description:

Add a background color to all headings in the page.

HTML code:
<h1>Header 1</h1>
<p>Contents 1</p>
<h2>Header 2</h2>
<p>Contents 2</p>
jQuery code:
$(":header").css("background", "#EEE");
Result:
[ <h1 style="background:#EEE;">Header 1</h1>, <h2 style="background:#EEE;">Header 2</h2> ]

Leave a Reply

Your email address will not be published. Required fields are marked *