From b6e6d28f25b1c5ea632145c904aa3e60ab57f1ef Mon Sep 17 00:00:00 2001 From: halmosigabor Date: Thu, 21 Mar 2019 17:52:22 +0100 Subject: [PATCH] add: file (#27924) --- .../html-dom-queryselectorall/index.md | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 guide/english/javascript/html-dom-queryselectorall/index.md diff --git a/guide/english/javascript/html-dom-queryselectorall/index.md b/guide/english/javascript/html-dom-queryselectorall/index.md new file mode 100644 index 0000000000..59b756c8b2 --- /dev/null +++ b/guide/english/javascript/html-dom-queryselectorall/index.md @@ -0,0 +1,43 @@ +--- +title: HTML DOM querySelectorAll +--- + +The Document method `querySelectorAll()` returns a static (not live) `NodeList` representing a list of the document's elements that match the specified group of selectors. + +**HTML content:** + +```html +
first div
+
second div
+element-example +another-element-example +``` + +**JavaScript content:** + +```javascript +document.querySelectorAll(".class-example"); // Returns all of the elements with class `class-example` +document.querySelectorAll("a"); // Returns all `a` element +``` + +**Note** +`querySelectorAll()` behaves differently than most common JavaScript DOM libraries, which might lead to unexpected results. + +Consider this HTML, with its three nested `
` blocks. +```html +
+
+
+
+
+
+``` +```javascript +var select = document.querySelector('.select'); +var inner = select.querySelectorAll('.outer .inner'); +inner.length; // 1, not 0! +``` + +#### More Information: + +MDN - document.querySelectorAll()