javascript 变量如何做常量用
有如下CASE
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
</head>
<body>
<div id="div1">div1</div>
<br>
<div id="div2">div2</div>
<br>
<div id="div3">div3</div>
<script language="javascript">
for(i=1;i<4;i++)
{
document.getElementById("div"+i).addEventListener("click",function (){
TellMe(i);}, //如何把这里的i转成,1,2,3
false);
}
function TellMe(cn)
{
alert(cn);
}
</script>
</body>
</html>
即要达到点"div1",alert(1);点"div2",alert(2);点"div3",alert(3);