SyntaxFix
Write A Post
Hire A Developer
Questions
The onclick property is all lower-case, and accepts a function, not a string.
onclick
document.getElementById("test").onclick = foo2;
See also addEventListener.
addEventListener