从我在这里的阅读中,我希望这段代码可以工作,但事实并非如此。我尝试了两种将点击事件添加到名为“lonext”的按钮的方法。都不工作。我不确定为什么会这样?
window.onload = function() {
var goSC = function() { //go to the sucess criteria section
document.getElementsByClassName("guidance1").style.display = "none";
document.getElementsByClassName("guidance2").style.display = "";
alert("button clicked");
//first try
document.getElementById("lonext").addEventListener("click", function() {
goSC();
}, false);
//second try
document.getElementById("lonext").onclick = goSC;
}