在Chrome中使用的javascript无法在IE中运行

时间:2014-04-26 11:56:34

标签: javascript internet-explorer

在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>

1 个答案:

答案 0 :(得分:4)

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

使用select上的onchange事件

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

FIDDLE