1
votes

HTML:

<span id="test">0</span>
<button onclick="test(test)">Test</button>

Javascript:

function test(id) {
document.getElementById(id).innerHTML = 1;
}

Uncaught Typeerror: Cannot set property innerHTML of null

1
mark it as answer if it helps - Amit Joki

1 Answers

2
votes
<button onclick="test('test')">Test</button>

This will work

A string is wrapped in '' or ""