課程
/前端開發(fā)
/JavaScript
/JavaScript進階篇
?????
2016-08-29
源自:JavaScript進階篇 6-11
正在回答
?document.getElementById("fruit")value=jieguo; ? value后面少個. ? ? ?
<input type='button' value=' = ' onclick="count()"/>
value中寫規(guī)范一些,雙引號中最好不要有空格
?document.getElementById("fruit")value=jieguo;?????? 差了一個點,就是document.getElementById("fruit").value=jieguo;?
document.getElementById("fruit").value=jieguo;
應寫在function之外
? <script type="text/javascript">
? ?function count(){
var txt1 ? = parseInt( document.getElementById('txt1').value);//獲取第一個輸入框的值
var txt2 ? = parseInt( document.getElementById('txt2').value);//獲取第二個輸入框的值
var select = document.getElementById('select').value;//獲取選擇框的值
var result = '';
switch (select)
{
case '+':
result = txt1 + txt2;
break;
case '-':
result = txt1 - txt2;
case '*':
result = txt1 * txt2;
case '/':
result = txt1 / txt2;
break; ?
}
? ? ? ? ?document.getElementById('fruit').value = result;//設置結(jié)果輸入框的值?
? ?}
? </script>?
舉報
本課程從如何插入JS代碼開始,帶您進入網(wǎng)頁動態(tài)交互世界
2 回答各位大神,錯在哪?
3 回答求各位大神找錯
2 回答哪位大神知道錯在哪
4 回答各位大神幫忙看看哪里錯了!
4 回答請各位大神幫看看哪里錯了?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學習伙伴
掃描二維碼關注慕課網(wǎng)微信公眾號
2016-08-29
?document.getElementById("fruit")value=jieguo; ? value后面少個. ? ? ?
<input type='button' value=' = ' onclick="count()"/>
value中寫規(guī)范一些,雙引號中最好不要有空格
2016-08-29
?document.getElementById("fruit")value=jieguo;?????? 差了一個點,就是document.getElementById("fruit").value=jieguo;?
2016-08-29
document.getElementById("fruit").value=jieguo;
應寫在function之外
2016-08-29
? <script type="text/javascript">
? ?function count(){
var txt1 ? = parseInt( document.getElementById('txt1').value);//獲取第一個輸入框的值
var txt2 ? = parseInt( document.getElementById('txt2').value);//獲取第二個輸入框的值
var select = document.getElementById('select').value;//獲取選擇框的值
var result = '';
switch (select)
{
case '+':
result = txt1 + txt2;
break;
case '-':
result = txt1 - txt2;
break;
case '*':
result = txt1 * txt2;
break;
case '/':
result = txt1 / txt2;
break; ?
}
? ? ? ? ?document.getElementById('fruit').value = result;//設置結(jié)果輸入框的值?
? ?}
? </script>?