日期:2014-05-16  浏览次数:20326 次

【求助】javascript如何获取area的属性??????
我的网页中有大量的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)" />

....

急啊,实在是不知道该怎么办了,望大家帮助!

------解决方案--------------------

<area shape="circle" coords="150, 0, 50" id="2" onclick="play(this.id)" />
<script type="text/javascript">

function play(a)
{
 alert(a);
}

</script>
这样可以获得