onclick of a button html change js code example Example: javascript change button onclick function Bar() { document.getElementById("a").onclick = Foo(); }