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