internet explorer-javascript在Chrome中有效,在IE中无效

internet explorer - javascript works in Chrome does not work in IE

本文关键字:IE 无效 有效 Chrome internet explorer-javascript      更新时间:2023-09-26

在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中的选项上附加鼠标事件,因此单击永远不会触发。

在select上使用onchange事件,而不是

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

FIDDLE