javascript,html画布问题,菜鸟不理解js代码

 <!DOCTYPE HTML>
<html>
<head>
<style type="text/css"> 
body
{
font-size:70%;
font-family:verdana,helvetica,arial,sans-serif;
}
</style>

<script type="text/javascript"> 
function cnvs_getCoordinates(e)
{
x=e.clientX;
y=e.clientY;
<!-- ↓↓下面这里获取的id是xycoordinates,不是coordiv为什么,下面不是规定了
一个id=coordiv的矩形框吗,要获取内容不是在这里获取吗? -->
document.getElementById("xycoordinates").innerHTML="Coordinates: (" + x + "," + y + ")";
}

function cnvs_clearCoordinates()
{
document.getElementById("xycoordinates").innerHTML="";
}
</script>
</head>

<body style="margin:0px;">

<p>把鼠标悬停在下面的矩形上可以看到坐标:</p>

<div id="coordiv" style="float:left;width:199px;height:99px;border:1px solid #c3c3c3" onmousemove="cnvs_getCoordinates(event)" onmouseout="cnvs_clearCoordinates()"></div>
<br />
<br />
<br />
<div id="xycoordinates"></div>
 <!-- ↑上面这句是什么作用?不是很理解清除坐标和获得坐标要获取这个id? -->

</body>
</html>

图片说明

因为数据要显示在xycoordinates这个div里面

你的数据都是放在这个div里面的 那么你告诉我为什么要取这个id? 因为拿到这个id就可以拿到这个div里面的数据。

第一次获取是给这个div赋值 第二次是清空

coordiv下面图形中显示的矩形 你鼠标放置显示坐标 而后面的div是用来显示坐标的 一个是图形 一个是显示框 这个够清楚了吧