div跟隨滑鼠懸浮顯示,div跟隨懸浮
<span style="font-size:18px;"><!doctype html><html lang="en"> <head> <meta charset="UTF-8"> <meta name="Generator" content="EditPlus®"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> <title>Document</title> </head><style> #hint{ width:198px; height:200px; border:1px solid #000000; background:#99ff33; position:absolute; z-index:9; padding:6px; line-height:17px; text-align:left; top:1520px; } </style> <script type="text/javascript"> function showme(){ var oSon = window.document.getElementById("hint"); if (oSon == null) return; with (oSon){ style.display = "block"; style.pixelLeft = window.event.clientX + window.document.body.scrollLeft + 6; style.pixelTop = window.event.clientY + window.document.body.scrollTop + 9; } } function hideme(){ var oSon = window.document.getElementById("hint"); if(oSon == null) return; oSon.style.display="none"; } </script> <body> <a href="#" onmouseover="showme()">測試div跟隨滑鼠懸浮顯示1</a><br/><br/> <a href="#" onmouseover="showme()" onmouseout="hideme()">測試div跟隨滑鼠懸浮顯示2</a><br/><br/> <a href="#" onmouseover="showme()" onmouseout="hideme()" onmousemove="showme()">測試div跟隨滑鼠懸浮顯示3</a><br/><br/> <a href="#" onmouseover="showme()" onmouseout="hideme()" >測試div跟隨滑鼠懸浮顯示4</a><br/><br/> <div id="hint" style="display:none" onmouseout="hideme()"> 哈哈哈哈哈哈 <input type="button" onclick="test()" value="按鈕"/> <a href="index.jsp">連結</a> </div> </body> </html></span>
效果: