1const allSpanElements = document.querySelectorAll('span');
2
3allSpanElements.forEach((spanElement) => {
4 // Here comes the Code that should be executed on every Element, e.g.
5 spanElement.innerHTML = "This Content will appear on every span Element now";
6});
1// This selects the first element with that name
2document.querySelector('[name="your-selector-name-here"]');
1The querySelectorAll() method returns all elements in the document
2that matches a specified CSS selector(s), as a static NodeList object.
3The NodeList object represents a collection of nodes.
4The nodes can be accessed by index numbers.
5The index starts at 0.
1// https://www.google.com/
2// this puts a border around the 'a' tags of 'Google offered in' section.
3
4// within this id find all the 'a' tags
5var languages = document.querySelectorAll("#SIvCob a");
6
7
8// loop through all the a tags a add a border to the tags
9for(var i = 0; i < languages.length; i++){
10 document.querySelectorAll("#SIvCob a")[i].style.border = "1px solid black";
11
12}
13