<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.selectedInd开发者_如何学运维ex].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>
The CSS left
and top
properties take lengths, not numbers. You are missing units.
精彩评论