为什么接收TypeError Null?

时间:2013-07-06 16:26:35

标签: javascript null

这可能是一个愚蠢的问题,但对javascript不熟悉我真的很沮丧。

我正在接收"TypeError: bajs is null" (line 2 in the js-file)。这是什么意思?我做错了什么?为什么不起作用?

这是javascript:

var bajs = document.getElementById("canvas1");
bajs.addEventListener("click", hejhej, false);

function hejhej() {alert("it's working");}

这是html:

<canvas id="canvas1" width="500px" height="350px"></canvas>

0 个答案:

没有答案