Selector API

1 - About

A selector is a boolean expression (known also as predicate) that match against elements in a DOM tree in order to select one or several node.

This API was known before as the CSS Selector API and was renamed to show that the selection is not only used by CSS but also by other technoclogy such as Javascript DOM selection.

A basic selector:

  • takes an element in a tree structure
  • and tests whether the element matches the selector or not.

selector can be grouped.

This mini-language consists of predicates expression that filter elements by:

3 - Usage

4 - Syntax

See Selector Overview.

Type Example Description
Universal Selector * Any element
Tag selector E An element of type E
Id Selector E#myid An E element with ID equal to myid
Id Selector #myid Any element with ID equal to myid (equivalent to *#myid)
Attribute selector E[foo] An E element with a foo attribute
Attribute selector E[foo=“bar”] An E element whose foo attribute value is exactly equal to bar

Type:

5 - Management

5.1 - Validate

To validate your selector on a HTML page, you can use the devtool

Example with :

Ref

6 - Reference


Data Science
Data Analysis
Statistics
Data Science
Linear Algebra Mathematics
Trigonometry

Powered by ComboStrap