querySelector method

  1. @DomName('Document.querySelector')
  2. @DocsEditable()
Element querySelector(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-level querySelector method 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 the CSS selector specification.

Source

@DomName('Document.querySelector')
@DocsEditable()
Element querySelector(String selectors) =>
    _blink.BlinkDocument.instance.querySelector_Callback_1_(this, selectors);

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/1.24.3/dart-html/Document/querySelector.html