This topic created in 4043 days ago, the information mentioned may be changed or developed.
<html>
<head>
<script type="text/javascript">
function alertValue()
{
alert(document.getElementById("text1").value)
}
</script>
</head>
<body>
<form>
<input type="text" id="text1" value="Hello world!" />
<input type="button" id="button1" onclick="alertValue()"
value="Show default value" />
</form>
</body>
</html>
我想这样
<html>
<head>
<script type="text/javascript">
alert(document.getElementById("text1").value)
</script>
</head>
<body>
<form>
<input type="text" id="text1" value="Hello world!" />
<input type="button" id="button1" onclick="alertValue()"
value="Show default value" />
</form>
</body>
</html>
就无法弹出alert,何解?
 |
|
1
tux Apr 3, 2015
因为alert的时候,要alert出来的东西还没有加载,把alert放在要alert的东西底下就好了
|