我的网页中有大量的area,每一个都有自己的编号,我想通过点击图像中的热点来触发事件,并在触发事件中得到被点击的热点的编号,请问怎么做?
我是这么做的,但是得不到效果:
....<script language="javascript">
function play(var id)
{
alert(id);
}
</script>....<area shape="circle" coords="0, 0, 50" id="1" onclick="alert(this.id)" />
<area shape="circle" coords="150, 0, 50" id="2" onclick="play(this.id)" />....急啊,实在是不知道该怎么办了,望大家帮助!
我是这么做的,但是得不到效果:
....<script language="javascript">
function play(var id)
{
alert(id);
}
</script>....<area shape="circle" coords="0, 0, 50" id="1" onclick="alert(this.id)" />
<area shape="circle" coords="150, 0, 50" id="2" onclick="play(this.id)" />....急啊,实在是不知道该怎么办了,望大家帮助!
这种方法可以得到
<area shape="circle" coords="150, 0, 50" id="2" onclick="play(this.id)" />
<script type="text/javascript">function play(a)
{
alert(a);
}</script>
这样可以获得
x=document.getElementById('venus');
如果我将ID直接写到函数中自然是最轻松了,但是也就没意义了。
我面前有200个area,难道还给它编200个响应函数不成?