Home > Web Front-end > JS Tutorial > jQuery selector: detailed explanation of header usage

jQuery selector: detailed explanation of header usage

黄舟
Release: 2017-06-23 10:47:29
Original
1750 people have browsed it

Overview

Match title elements such as h1, h2, h3

Example

Description:

Add to all titles in the page Background color

HTML code:

<h1>Header 1</h1> <p>Contents 1</p> <h2>Header 2</h2> <p>Contents 2</p>
Copy after login

jQuery Code:

$(":header").css("background", "#EEE");
Copy after login

Result:

[ <h1 style="background:#EEE;">Header 1</h1>, <h2 style="background:#EEE;">Header 2</h2> ]
Copy after login

This The selector can match heading elements, i.e. (h1-h6).

Grammar structure:

$(":header")
Copy after login

This selector is generally used in conjunction with other selectors, such as Class selector and Element selector, etc. wait. For example:

$(".qiantai:header").css("color","blue")
Copy after login

The above code can set the font color in the title element with the class name qiantai to blue.

If not used with other selectors, the default state is to be used with the * selector. For example, $(":header") is equivalent to $("*: header").

Example code:

Example 1:






脚本之家 
 
 

    前台专区版块

  • html专区
  • div+css专区
  • jQuery专区
  • Javascript专区

    后台专区版块

  • ASP专区
  • php专区
Copy after login

##The above code can be used to title the class attribute value of qiantai The text color in the element is set to blue.

Example 2:






脚本之家 
 
 

    前台专区版块

  • html专区
  • div+css专区
  • jQuery专区
  • Javascript专区

    后台专区版块

  • ASP专区
  • php专区
Copy after login


Since the above code does not specify a selector to be used with the :header selector, it defaults to the * selector Used together, the above code can set the text color of the title element in all elements in the current document to blue.

The above is the detailed content of jQuery selector: detailed explanation of header usage. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template