querySelector method - Document class - dart:html library (original) (raw)

Element? querySelector(

  1. String selectors )

Finds the first descendant element of this document that matches the specified group of selectors.

Unless your webpage contains multiple documents, the top-levelquerySelectormethod behaves the same as this method, so you should use it instead to save typing a few characters.

selectors should be a string using CSS selector syntax.

var element1 = document.querySelector('.className');
var element2 = document.querySelector('#id');

For details about CSS selector syntax, see theCSS selector specification.

Implementation

Element? querySelector(String selectors) native;