74 of 119 menu

Header selector

The selector :header selects headers h1, h2, h3, h4, h5, h6. Since :header is not part of the CSS specification, it is better to use it in modern browsers to improve performance. First filter the elements using a pure css selector, then apply .filter(':header').

Syntax

This is how we select elements:

$(':header');

Example

Let's change the background of all headings to gray:

<h1>Header h1</h1> <p>text</p> <h2>Header h2</h2> <p>text</p> $(':header').css({background: '#ccc'});

See also

  • method filter,
    which filters elements in a set by a given selector
  • method css,
    which allows you to get and change the CSS styles of an element
English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline