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>
jQuery Code:
$(":header").css("background", "#EEE");
Result:
[ <h1 style="background:#EEE;">Header 1</h1>, <h2 style="background:#EEE;">Header 2</h2> ]
This The selector can match heading elements, i.e. (h1-h6).
Grammar structure:
$(":header")
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")
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:
##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:
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!