we_are伐木累o_0
2016-01-07 14:09
function aa(){
var aa1=prompt("nishi","22");
if(aa1!=" "){
alert(1)
}else{
alert(2)
}
}
var cli=document.getElementById("aac");
cli.addEventListener('click',aa,true)
</script>
</head>
<body>
<form action="">
<input type="text" value="1" id="a">
<select name="" id="d">
<option value="+">+</option>
<option value="-">-</option>
<option value="/">/</option>
<option value="*">*</option>
</select>
<input type="text" value="2" id="b">
<input type="button" value=" = " onclick="math1()">
<input type="text" id="c">
<input type="text" id="clock" value="5"><button id="aa22" >abc</button>
<input type="button" value="aa" id="aac">
不要直接复制啊,<script type="text/javascript"> 的type值我忘了写了
<html>
<head></head>
<body>
<form action="">
<input type="text" value="1" id="a">
<select name="" id="d">
<option value="+">+</option>
<option value="-">-</option>
<option value="/">/</option>
<option value="*">*</option>
</select>
<input type="text" value="2" id="b">
<input type="button" value=" = " onclick="math1()">
<input type="text" id="c">
<input type="text" id="clock" value="5"><button id="aa22" >abc</button>
<input type="button" value="aa" id="aac">
</body>
</html>
<script>
function aa(){
var aa1=prompt("nishi","22");
if(aa1!=" "){
alert(1)
}else{
alert(2)
}
}
var cli=document.getElementById("aac");
cli.addEventListener('click',aa,true)
</script>
你的JavaScript代码在id=aac标签加载之前就被加载了,在那时,DOM里面没有id=aac的<input>标签,你可以将script脚本全都放到</html>后面
DOM事件探秘
99545 学习 · 1197 问题
相似问题