下拉列表中所选选项的描述适用于除Firefox之外的所有浏览器;如何修复

The description of the selected option in dropdown works on all the browsers except Firefox; how to fix it?

本文关键字:浏览器 何修复 选项 描述 下拉列表 适用于 Firefox      更新时间:2023-09-26
<html    
<head>    
    <title>Dropdown tooltip</title>    
</head>    
    
<body style="font-size:10pt;font-family:Verdana;">    
<script language="javascript">    
function showTip(oSel) {    
    var theTip = document.getElementById("spnTip");    
    theTip.style.top = window.event.clientY + 20;    
    theTip.style.left = window.event.clientX;    
    theTip.innerText = oSel.options[oSel.selectedIndex].text;    
    theTip.style.visibility = "visible";    
    }
        
function hideTip() {    
    document.getElementById("spnTip").style.visibility = "hidden";    
    }    
</script>
<form>    
<select style="width:100px;" onchange="showTip(this)">    
<option>Have you seen the latest M. Night Shyamalan film?</option>    
<option>It's called The Village.</option>    
<option>Although the critics didn't like it, I think it was extremely well done.</option>    
<option>You will be kept in suspense even if you think you have figured out the ending.</option>    
</select>
<span id="spnTip"    
 style="position:absolute;visibility:hidden;background:lightyellow;    
 border:1px solid gray;padding:2px;font-size:8pt;font-family:Verdana;"    
 onMouseOut="hideTip()"></span>    
<br /><br /><br />    
</form>    
</body>    
</html>

CSS lefttop属性采用长度,而不是数字。你缺少单位。