我正在尝试以编程方式创建HTML 5滑块
var inputElem = document.createElement("input");
inputElem.id = "opacity_" + layer.name;
inputElem.name = "opacity_" + layer.name;
inputElem.type = "range";
inputElem.min = "0";
inputElem.max = "100"; //debugger;
inputElem.value = "100";
inputElem.step= "1";
inputElem.style.zIndex = "10000";
var fnChange = function () {alert(layer.name) ; };
inputElem.onchange = fnChange;
但是我无法设置onchange事件,它保持为null,并且在浏览器中查看时, no onchange ,如
<input type="range" min="0" max="100" value="100">
我使用的是Google Chrome 10.0.648.134
我做错了什么?