javascript onclick happening on page load

javascript, onclick

Solution

Try this

function zoom()
{
    alert("test!");
}
document.getElementById("us").onclick=zoom;

Problem

I'm trying to make a simple Javascript function to open a window with a bigger image when an image is clicked on. What happens is this test alert pops up on the page load and then does nothing when i click on the image. Here is the code ``` function zoom() { alert("test!"); } document.getElementById("us").onclick = zoom(); ``` ``` <img id="us" src="http://placekitten.com/200/200" /> ```

Original source