I'm trying to change the value of a button when I click on it, so what I did was I created a function in JavaScript where I call the ID of the element by getting the ID of the button and through style.backImage try and change it.
But it shows this error:
Uncaught TypeError: Cannot set properties of null (setting 'value')
This is the code of the button:
<button id="id1" style="margin: 17px;" onclick="mark()"> . </button>
And the JavaScript function is the following:
function mark(){
document.getElementById(id1).style.backgroundImage = "url('cruz.webp')";
}
I've tried moving the JavaScript document from the head to body in HTML but hasn't done any good.
I know it must be really simple but I appreciate your help.