关于js问题 请求大家帮忙
程序代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www. xmlns="http://www. http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>显示、隐藏弹出层的例子</title> <style type="text/css"> body{ color:#008000; font:12px/1.5 arial; } a{ color:#0B59B2; margin:0 8px; } #box{ position:absolute; width:230px; height:60px; background:#F5F9FA; border:2px solid #95B5D5; display:none; } </style> <script type="text/javascript"> window.onload = function () { var aA = document.getElementsByTagName("a"); var oBox = document.getElementById("box"); var timer = null; var i = 0; for (; i < aA.length; i++) { aA[i].onmouseover = function () { clearTimeout(timer); var oParent = this.parentElement || this.parentNode; oBox.style.top = pageY(this) + this.offsetHeight + 5 + "px"; oBox.style.left = pageX(oParent) + "px"; oBox.style.display = "block" }; aA[i].onmouseout = oBox.onmouseout = function () { timer = setTimeout(function () { oBox.style.display = "none" }, 300) }; oBox.onmouseover = function () { clearTimeout(timer); } } }; function pageX (elem) { return elem.offsetLeft + (elem.offsetParent ? arguments.callee(elem.offsetParent) : 0) } function pageY (elem) { return elem.offsetTop + (elem.offsetParent ? arguments.callee(elem.offsetParent) : 0) } </script> </head> <body> <p>作者:<a href="javascript:;">swiss原子弹</a>发表日期:211-8-17 21:56:00</p> <p>作者:<a href="javascript:;">可乐马驹</a>发表日期:211-8-17 21:56:00</p> <p>作者:<a href="javascript:;">网友网友love</a>发表日期:211-8-17 21:56:00</p> <div id="box"></div> </body> </html>
其中
var aA = document.getElementsByTagName("a");指定的是a标记 我想这样
<p>作者:<a href="javascript:;">swiss原子弹</a>发表日期:211-8-17 21:56:00</p>给a标记定义一个id
<p>作者:<a id="pop" href="javascript:;">swiss原子弹</a>发表日期:211-8-17 21:56:00</p>这样怎么做才能是这段程序运行成功