JavaScript練習題目(1)按鈕改變文字域值

鍾超發表於2011-11-15
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>My First Script</title>
<script type="text/javascript">
function test() {
	var temp = document.getElementById('input_text');
	temp.value = '哈哈';
}
</script>
</head>
<body>
<form>
	<label>輸入</label><input id="input_text" type="text" value="預設值" />
	<input type="button" value="設定為'哈哈'" onclick="test();" />
</form>
</body>
</html>

相關文章