【发布时间】:2021-09-04 16:38:59
【问题描述】:
如何存储此按钮的 ID 值,以便在其他无法点击的功能上使用它?
<button id="1" onclick="myfunction(this.id)">Click Here</button>
function myfunction(clicked){
var thisnum = clicked;
document.querySelector(".holder--" + thisnum).classlist.add("store")
}
function secondfunction(){
document.querySelector(".box--" + thisnum).classlist.remove("store")
}
【问题讨论】:
-
a)
var在myfunction内,它不是全局的 b) 你在哪里调用secondfunction?
标签: javascript function variables