onEvent("pb" + 1, "click", function() {
console.log(("pb" + 1) + " was clicked!");
});
onEvent("pb" + 2, "click", function() {
console.log(("pb" + 2) + " was clicked!");
});
onEvent("pb" + 3, "click", function() {
console.log(("pb" + 3) + " was clicked!");
});
onEvent("pb" + 4, "click", function() {
console.log(("pb" + 4) + " was clicked!");
});
我必须编写其中的 80 个函数......
我想这样做,所以我可以使用一个变量来包含 1-80 的范围:
onEvent("pb" + [1, 80], "click", function() {
console.log(("pb" + [1, 80]) + " was clicked!");
});
我不确定是否可以将变量定义为一组单独的数字。
青春有我
繁星点点滴滴
相关分类