gpt4 book ai didi

javascript 在 Chrome 中有效,在 IE 中无效

转载 作者:行者123 更新时间:2023-11-30 10:16:41 24 4
gpt4 key购买 nike

在 Chrome 浏览器中,当您单击此网页上的 CloudCover 时,会在下面显示一段说明。在 IE 中,不会显示描述。有什么建议可以使它在 IE 中运行吗?

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>min test</title>
<script type='text/javascript'>
function showDescription (sel) {
var myVarDescip, myVarTEXT;
var myVar = (sel.value);
document.getElementById('putDescriptionHere').innerHTML = "";
myVarDescip = (myVar + "Descrip");
myVarTEXT = document.getElementById(myVarDescip).innerHTML;
document.getElementById('putDescriptionHere').innerHTML = myVarTEXT;
}
</script>
</head>
<body>
<select id="destSelect" size="3" multiple="multiple">
<option value="CloudCover" onclick="showDescription(this);">Cloud Cover</option>
</select>
<div id="CloudCoverDescrip" style="display: none">
<b>Cloud Cover:</b> The percentage of sky occluded by clouds.
</div>
<div id="putDescriptionHere"></div>
</body>
</html>

最佳答案

您不能在 IE 中的选项上附加鼠标事件,因此点击永远不会触发。

改为在选择上使用 onchange 事件

<select id="destSelect" size="3" multiple="multiple" onchange="showDescription(this);">

FIDDLE

关于javascript 在 Chrome 中有效,在 IE 中无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23310510/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com