每当有人在输入文本字段中输入大于 0 的数字并点击提交按钮时,我希望能够在 div 容器中返回某个输出。我不确定我做错了什么。任何帮助将不胜感激!
HTML
<!DOCTYPE html>
<html>
<head>
<title>Button Magic</title>
<link rel='stylesheet' type='text/css' href='Jquery.css'/>
<script type="text/javascript" src="Jquery.js"></script>
</head>
<body>
<!-- Input Field-->
<input type="text" id="first" maxlength="6" placeholder="0.00">
<!-- Span -->
<span>< Type here</span>
<!-- Submit -->
<button onclick="submitNumber()">Submit</button>
<!-- Output -->
<div id="textOutput">
Are you correct?
</div>
</body>
</html>
JAVASCRIPT
function submitNumber() {
textInput = document.getElementById('first');
textOutput = document.getElementById('textOutput');
if (textInput > 0) {
textOutput.innerHTML = 'Correct!';
} else {
textOutput.innerHTML = 'Incorrect!';
}
}