html 5 slider onchange事件

时间:2011-03-18 14:48:37

标签: html5 javascript-events slider onchange

我正在尝试以编程方式创建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

我做错了什么?

1 个答案:

答案 0 :(得分:0)

似乎没有本机onchange事件,但jquery提供了一个:onChange event for HTML5 range