simply put i want to change all the values in headings to 't' when a button is pressed so i have the following code there are no errors
what i expect to happen is for all headings to change their content to 't'
window.onload = function () {
let specialButton = document.getElementById('mainButton')
specialButton.addEventListener('click', removeHeadings())
function removeHeadings () {
for (var j = 1, length = 7; j < length; j++) {
let headings = document.getElementsByName('h' + j)
for (var i = 0, len = headings.length; i < len; i++) {
headings[i].innerHTML = 't '
}
}
}
}
<h1>s</h1>
<h2>s</h2>
<h3>s</h3>
<button id="mainButton">Remove Headings</button>
also please tell me why the above does not work
getElementsByTagName