我懵了,求大神
<html>
<head>
<script>
window.onload=function()
{
?? ?
??? document.getElementById("but").onclick=function()
??? {
??????? alert("you hurt me!!!");
??? }
??? document.write("aaaaaa");
}
document.write("bbbbbbbbbbbbb");
</script>
</head>
<body>
<input id="but" type="button" value="click me" >
<script>
document.write("asssss");
</script>
</body>
</html>
這是我的代碼,為啥當b為偶數(shù)的時候,都會顯示出來,b為奇數(shù)的時候,只顯示aaaaaa????
2016-06-24
不明白你說的b是什么意思,但就你這些代碼來說,window.onload是文檔加載完之后做的事情,window.onload設(shè)置的函數(shù)把整個文檔覆蓋掉了,window.onload是文檔加載完之后做的事情,覆蓋掉之后沒辦法點擊but了,只能輸出aaaaaa
2016-06-24
你的代碼中變量b 在那里,沒有看到。你想要實現(xiàn)什么效果?