html 5滑块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 事件,它保持为空,并且在浏览器中查看时没有 onchange,就像
<input type="range" min="0" max="100" value="100">
我 一样我正在使用 Google Chrome 10.0.648.134
我做错了什么?
I am trying to programatically create HTML 5 slider
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;
However I can't set the onchange event, it stays null, and when viewed in the browser there is no onchange as in
<input type="range" min="0" max="100" value="100">
I am using Google Chrome 10.0.648.134
What have I done wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
似乎没有原生的 onchange 事件,但 jquery 提供了一个: HTML5 range 的 onChange 事件
It appears there is no native onchange event, but jquery provides one: onChange event for HTML5 range