課程
/前端開發(fā)
/JavaScript
/JavaScript進(jìn)階篇
為什么fruit文本框獲取不到值
2015-12-16
源自:JavaScript進(jìn)階篇 6-11
正在回答
result = document.getElementById('fruit').value ;
然后后面在fruit那里寫成 ?value = result為什么不能運(yùn)行?
? ?switch(select){
? ? ? ? case "+":
? ? ? ? ? ? result=parseInt(txt1)+parseInt(txt2);
? ? ? ? ? ? break;
? ? ? ? case "-":
? ? ? ? ? ? result=parseInt(txt1)-parseInt(txt2);
? ? ? ? case "*":
? ? ? ? ? ? result=parseInt(txt1)*parseInt(txt2);
? ? ? ? default:
? ? ? ? ? ? result=parseInt(txt1)/parseInt(txt2);
? ? }
? ? //設(shè)置結(jié)果輸入框的值?
? ? document.getElementById("fruit").value = 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;
mosci
提問最好貼一下代碼,不然誰知道你問什么
把你寫的代碼貼出來看看
取值方法:document.getElementById("fruit").value = result;
你得把你代碼貼出來,我們才能知道你錯哪了啊
舉報
本課程從如何插入JS代碼開始,帶您進(jìn)入網(wǎng)頁動態(tài)交互世界
1 回答第三個文本框是沒有獲取到值?
5 回答JS獲取輸入框的值
6 回答為什么方法最后把結(jié)果輸出到fruit文本框那里不能這樣寫?
5 回答獲取下拉選擇框的值
2 回答本節(jié)如何通過nodeValue獲取文本節(jié)點的值啊
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2015-12-20
result = document.getElementById('fruit').value ;
然后后面在fruit那里寫成 ?value = result為什么不能運(yùn)行?
2015-12-16
? ?switch(select){
? ? ? ? case "+":
? ? ? ? ? ? result=parseInt(txt1)+parseInt(txt2);
? ? ? ? ? ? break;
? ? ? ? case "-":
? ? ? ? ? ? result=parseInt(txt1)-parseInt(txt2);
? ? ? ? ? ? break;
? ? ? ? case "*":
? ? ? ? ? ? result=parseInt(txt1)*parseInt(txt2);
? ? ? ? ? ? break;
? ? ? ? default:
? ? ? ? ? ? result=parseInt(txt1)/parseInt(txt2);
? ? }
? ? //設(shè)置結(jié)果輸入框的值?
? ? document.getElementById("fruit").value = result;
2015-12-16
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;
2015-12-16
提問最好貼一下代碼,不然誰知道你問什么
2015-12-16
把你寫的代碼貼出來看看
2015-12-16
取值方法:document.getElementById("fruit").value = result;
你得把你代碼貼出來,我們才能知道你錯哪了啊