jQuery :header Selector

Last Updated : 11 Jul, 2025

The jQuery :header Selector is used to select all the heading elements that are from (

to
). 

Syntax: 

$(":header") 

Example 1: Change the color of all headings to green. 

HTML

<html>

<head>
    <title>jQuery :header Selectortitle>
    <script src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
    script>
    <script>
        $(document).ready(function () {
            $(":header").css(
                "color", "green");
        });
    script>
head>

<body>
    <center>
        <h1>GeeksForGeeksh1>
        <h2>jQuery :header Selectorh2>
        <div style="color:orange;">
            GeeksForGeeks
        div>
        <h5>A computer science
            portal for geeks.
        h5>
        <p style="color:dodgerblue">
            Sudo Placement
        p>
        <p>GFGp>
    center>
body>

html>

Output:

  

Example 2: Change the color of all headings to blue by clicking the button. 

HTML

<html>

<head>
    <script src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
    script>
    <script>
        $(document).ready(function () {
            $("button").click(function () {
                $(":header").css(
                    "color", "blue");
            });
        });
    script>
head>

<body>
    <center>
        <h1>GeeksForGeeksh1>
        <h2>jQuery :header Selectorh2>
        <div>GeeksForGeeksdiv>
        <h5>A computer science
            portal for geeks.
        h5>
        <p>GFGp>
        <button>Change colorbutton>
    center>
body>

html>

Output:

Supported Browsers: The browser supported by jQuery :Header Selector are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari

Comment

Explore