gpt4 book ai didi

javascript - "class is a reserved identifier"我的 javascript 有什么问题

转载 作者:行者123 更新时间:2023-11-30 13:23:33 25 4
gpt4 key购买 nike

我正在尝试使用原型(prototype) javascript 框架。我有下一个代码

CheckBoxSlider = Class.create({
initialize: function (checkbox, block) {
this.checkbox= $(checkbox);
this.block=$(block);
this.checkbox.observe("click", this.onClick.bind(this));
},
onClick: function (event) {
alert("Hello");
}
});
window.onload= function() {
tmp = new CheckBoxSlider("register-new-user","regiser-new-user-fields");
};

但是在警报后点击我得到错误“类是保留标识符”怎么了?

对不起,是我的错。脚本工作正常,问题出在 html 中

最佳答案

可能是您忘记加载原型(prototype)脚本,或者您自己的脚本后加载了原型(prototype)脚本?您的代码片段在 this jsfiddle 中有效

关于javascript - "class is a reserved identifier"我的 javascript 有什么问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9358864/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com