I have some code where I want to insert some HTML on the click of the button. But when I click that button, I get the following error:
TypeError: piecesLocation.insertAdjacentHTML is not a function
When inspecting the underlying code in the browser, I get this:
The code that gets triggered when I click a button is this:
function showValues() {
const piecesLocation = document.getElementsByClassName('pieces');
piecesLocation.insertAdjacentHTML('afterend', '<g class="values"></g>');
}
What is wrong with my code that causes it to trigger this error?