本帖最后由 zx3232793 于 2012-10-29 17:56:52 编辑

解决方案 »

  1.   


      var a=document.getElementById("a");  bind(a,"mouseover",function(e){
        alert("后来绑定的事件");
      });
      

  2.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <script type="text/javascript">
    function init(){
    var as=document.getElementsByTagName("a");
    for(var i=0;i<as.length;i++){
    as[i].onmouseover=show;
    as[i].onmouseout=hide;
    }
    var div=document.createElement("div");
    div.style.position="absolute";
    div.setAttribute("id","test");
    div.style.display="none";
    div.style.backgroundColor="blue";
    document.body.appendChild(div)
    }
    function show(e){
    var a=e||window.event;
    var x=a.clientX;
    var y=a.clientY;
    var div=document.getElementById("test");
    var ax=this.getAttribute("context");
    div.style.display="block";
    div.style.left=parseInt(x)+"px";
    div.style.top=parseInt(y)+"px";
    div.innerHTML=ax;
    }
    function hide(){
    var div=document.getElementById("test");
    div.style.display="none";
    }
    window.onload=init;
    </script>
    </head><body>
    <a context="test1">1</a>
    <a context="test2">2</a>
    <a context="test3">3</a>
    <a context="test4">4</a>
    <a context="test5">5</a>
    </body>
    </html>
    这样试试