本身作了個JS文件,將JS導入到文件中,在要顯示提示的標籤上加入hint=「提示內容」,運行時就可顯示提示javascript
//頁面元素提示框 var tishi = null; document.onmousemove=function(){ //判斷頁面元素中是否已經建立過div,沒有則建立,有則不建立 if(!tishi){ //建立div標籤元素 tishi = document.createElement("div"); //給div標籤元素添加樣式 tishi.style.position="absolute"; tishi.style.fontSize="9pt"; tishi.style.border="1px solid black"; tishi.style.background="lightyellow"; //將div元素添加到body中 document.body.appendChild(tishi); tishi.style.display="none" } //判斷元素中有沒有「h2int」屬性,有則顯示提示div if(event.srcElement.hint) { tishi.style.display="block"; tishi.innerHTML=event.srcElement.hint; tishi.style.left=window.event.clientX+10; tishi.style.top=window.event.clientY+10+document.documentElement.scrollTop; setTimeout("tishi.style.display='none'",8000); }else{ tishi.style.display="none" } }