if(p.length==ul.length){
for(i=0;i<p.length;i++){
p[i].onclick=function(){
if(ul[i].style.display=="block"){
ul[i].style.display="none"
}
for(i=0;i<p.length;i++){
p[i].onclick=function(){
if(ul[i].style.display=="block"){
ul[i].style.display="none"
}
誰能告訴我這樣為嘛不行????[email protected]
window.onload=function(){
var p =document.getElementById("menu").getElementsByTagName("p");
var ul = document.getElementById("menu").getElementsByTagName("ul");
window.onload=function(){
var p =document.getElementById("menu").getElementsByTagName("p");
var ul = document.getElementById("menu").getElementsByTagName("ul");
定時器函數中this.id中的this指向window對象,應該不是定時器函數引起的,但凡是函數內部嵌套的函數,該嵌套函數只要不是事件調用函數,這個內部函數的this都是指向全局window對象的。
2016-08-31