I try to change a paragraph by hovering over it.
HTML
<p id="foo"> Hello world! </p>
Javascript
var foo = document.getElementById("foo");
foo.addEventListener("mouseover", ChangeText("Goodbye world!"));
function ChangeText(s) {
this.innerHTML = s;
}
Yet the paragraph doesn't change on hover. When the parameter is left out and the string is directly typed like below it does work. Why?
var foo = document.getElementById("foo");
foo.addEventListener("mouseover", ChangeText);
function ChangeText() {
this.innerHTML = "Goodbye world!";
}