当用户在文本字段中输入文本并单击提交按钮时,他们的文本应该出现在屏幕上。现在什么都没有显示。
JS 斌:http: //jsbin.com/itotub/1/edit
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script>
function myOnloadFunc() {
var inputAnswer = document.getElementById("inputAnswer");
var userAnswer = inputAnswer.innerHTML;
var submitButton = document.getElementById("submitButton");
submitButton.onclick = function() {
document.write(userAnswer);
};
}
window.onload = myOnloadFunc;
</script>
</head>
<body>
<input type="text" id="inputAnswer" placeholder="Enter your answer">
<input type="button" id="submitButton" value=">">
</body>
</html>