我有一个html文件,我试图在其外部调用Js函数。
有人可以帮我解决下面的3个编号问题
document.getElementById('aa-button').addEventListener("click", toggleMenu);
function toggleMenu(){
var targetDiv = document.getElementById("aa-navigation__items");
debugger; //1) THIS IS NOT WORKING
console.log(targetDiv); //THIS RETURNS THE CORRECT THING
targetDiv.classList.toggle("reveal"); //2) THIS DOES NOT WORK
targetDiv.className += " reveal"; //THIS DOES WORK
}
3)如何在没有事件监听器的情况下调用该函数?