Jasper
0
Q:

document.queryselectorall

var matches = document.querySelectorAll("div.note, div.alert");
1
// This selects the first element with that name
document.querySelector('[name="your-selector-name-here"]');
2
event.stopPropagation();
2
let x = document.querySelectorAll(".example"); 
2
element = document.querySelector(selectores);
0
<div id="foo\bar"></div>
<div id="foo:bar"></div>

<script>
  console.log('#foo\bar');               // "#fooar" (\b is the backspace control character)
  document.querySelector('#foo\bar');    // Does not match anything

  console.log('#foo\\bar');              // "#foo\bar"
  console.log('#foo\\\\bar');            // "#foo\\bar"
  document.querySelector('#foo\\\\bar'); // Match the first div

  document.querySelector('#foo:bar');    // Does not match anything
  document.querySelector('#foo\\:bar');  // Match the second div
</script>
1
//Get the first element in the document with class="example":
document.querySelector(".example");
/*
The querySelector() method returns the first element that matches a specified CSS selector(s) in the document.
Note: The querySelector() method only returns the first element that matches the specified selectors. To return all the matches, use the querySelectorAll() method instead.
If the selector matches an ID in document that is used several times (Note that an "id" should be unique within a page and should not be used more than once), it returns the first matching element.
*/

//example :
//https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_document_queryselector_class
0
document.querySelectorAll
-2

New to Communities?

Join the community