2

代码:

单击时不执行相应的功能

<body onload="initialize('2.44','12.331')" onunload="triggerUnLoad()">
        <select>
            <option onclick="initialize('2.44331','2.442211')">-sel places-</option>
            <option onclick="initialize('1.2','1.8')">china</option>
            <option onclick="initialize('1.3','1.2')">brazil</option>        
            <option onclick="initialize('1.4','13.3')">australia</option>
        </select>

Onclick功能不工作

4

1 回答 1

5

<option>在某些浏览器中,元素没有点击事件。相反,您应该为元素使用change事件:<select>

<select onchange="initialize.apply(null, this.value.split(','));">
    <option value="2.44331,2.442211">-sel places-</option>
    <option value="1.2,1.8">china</option>
    <option value="1.3,1.2">brazil</option>        
    <option value="1.4,13.3">australia</option>
</select>

演示:http: //jsfiddle.net/SgFKj/

于 2012-12-05T14:28:43.290 回答