I have a function called showText()
which copies some text from form textbox to a paragraph elsewhere. It is called with the following:
document.getElementById("mybutton").onclick = showText;
It will not work if I add the () to the end of showText, which I understand from reading similar answers here is the only way to call a function.
Later in the script it requires the () to work:
window.addEventListener("keypress", function(e) {
var keycode = e.keyCode;
if (keycode == 13) {
showText();
}
}, false);
I'm not sure what is going on here.