尝试根据单击的按钮将文本框中的值加 1 或减 1。不能上班……不知道怎么了
<!DOCTYPE HTML>
<html>
<head>
<title>Add and Subtract Numbers</title>
<body>
<script>
function display(buttonclickedvalue)
{
switch (buttonclickedvalue)
{
case"+"
var number= parseInt(document.getElementById('numbertxt').value);
number.value = number + 1;
break;
case"-"
var number1= parseInt(document.getElementById('numbertxt').value);
number1.value = number1 -1;
break
}
}
</script>
<form name="calculations">
<input type = text id="numbertxt">
</br>
<input type = button value="+" onclick="display(this.value)">
<input type = button value="-" onclick="display(this.value)">
</form>
</body>
</head>
</html>
小提琴Here