Message from JavaScript discussions
June 2018
— 1. NodeLists don't have .map
2. You're mapping elements to strings now, this would return a list of uppercased strings, which is pointless
Juzuz. its hot in here. i have about 40 degrees. questions are.. very simple, ye. never heard about getElementByClass. querySelectorAll i suppose..
— It might be classname
— And plural
— GetElementsBy* -> NodeList
getElementBy* -> Element
— Sorry guys.. It's a typo.. After some testing.. This is what is Working for me
var elements=document.getElementsByClassName("test")
console.log(elements)
for(var i=0;i<elements.length;i++){
elements[i].innerText=elements[i].innerHTML.toUpperCase()
}
— You can remove the console code...
— The line
elements[i].innerText=elements[i].innerHTML.toUpperCase()
— Can also and should be
elements[i].innerHTML=elements[i].innerHTML.toUpperCase()
—
Array.from(document.getElementsByClassName('test'))
.forEach(element =>
element.textContent =
element.textContent.toUpperCase());
— Mh...thats cool...I tried the map and forEach and the browser could not allow it...creating an array from it is new to me...but it works!!
— For testing purposes, the first line should be ....Array.from(document.getElementsByClassName('test'))...