0
<script type="text/javascript">
function getvalue(data)
{
document.getElementById('result').value+=data;
}
function getequalto()
{
var text=document.getElementById('result').value;
var re=eval(text);
document.getElementById('result').value=re;
}
function plus()
{
document.getElementById('plus').style="visibility:hidden";
}
</script>
<input type="text" id="result"><br><br>
<input type="button" value="1" id="btn" onclick="getvalue(this.value)">
<input type="button" value="2" id="btn" onclick="getvalue(this.value)">
<input type="button" value="3" id="btn" onclick="getvalue(this.value)">
<input type="button" value="+" id="plus" onclick="getvalue(this.value) plus()">
<input type="button" value="=" id="btn" onclick="getequalto()">
我要點擊「+」按鈕可以消失,但是這不應該是顯示在輸入文本費爾德,即點擊後在'='按鈕上,結果應該由該操作員計算。如何按鈕的值傳遞給輸入文本字段,但其值應在文本字段中使用JavaScript
如果我將可見性隱藏方法應用於'+'運算符,然後隱藏但不計算值。
ID必須是獨特。 –
[___文檔中不得有多個'元素',它們具有相同的'id'值.___](https://www.w3.org/TR/html-markup/global-attributes.html#common .attrs.id) – Rayon
只要刪除所有的'ID'屬性,你就可以走了...... – Rayon