JS_簡單實現頁面輸入

Pop_Rain發表於2017-07-07

<!DOCTYPE html>
<html>
<head>
<title>13th_test</title>
<meta charset="gb2312">
</head>

<body>
<h1>這是一個標題</h1>
<p>這是一段文字</p>

<input id="name" type="text">
<input id="job" type="text">
<button type="button" onclick="fun()">點選這裡奇蹟出現</button>

<script>
function fun(name, job)
{
	var name = document.getElementById("name").value;
	var job = document.getElementById("job").value;
	window.alert(name+ " is a " + job);
} 
</script>
</body>
</html>

output:


相關文章