亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

javascript 初級的東西 alert("1");這個都彈不出來

javascript 初級的東西 alert("1");這個都彈不出來

那管你的 2017-05-10 01:16:49
<!DOCTYPE html><html><head> ? ?<title> 事件</title> ? ?<script type="text/javascript"> ? ? ? ?function count() { ? ? ? ? ? ?//獲取第一個輸入框的值 ? ? ? ? ? ?var text1 = document.getElementById("text1").value; ? ? ? ? ? ?alert('1'); ? ? ? ? ? ?//獲取第二個輸入框的值 ? ? ? ? ? ?var text2 = document.getElementById("text2").value; ? ? ? ? ? ?//獲取選擇框的值 ? ? ? ? ? ?var sel = document.getElementById("select").value; ? ? ? ? ? ?switch (sel) { ? ? ? ? ? ? ? ?case "+": ? ? ? ? ? ? ? ? ? ?document.getElementById("fruit").value = text1 * 1 + text2 * 1; ? ? ? ? ? ? ? ?case "-": ? ? ? ? ? ? ? ? ? ?document.getElementById("fruit").value = text1 * 1 - text2 * 1; ? ? ? ? ? ? ? ?case "*": ? ? ? ? ? ? ? ? ? ?document.getElementById("fruit").value = text1 * 1 + (text2 * 1); ? ? ? ? ? ? ? ?case "/": ? ? ? ? ? ? ? ? ? ?document.getElementById("fruit").value = text1 * 1 + (text2 * 1); ? ? ? ? ? ?} ? ? ? ?} ? ?</script></head><body><input type='text' id='txt1'/><select id='select'> ? ?<option value='+'>+</option> ? ?<option value="-">-</option> ? ?<option value="*">*</option> ? ?<option value="/">/</option></select><input type='text' id='txt2'/><input type='button' value=' = ' onclick="count()"/> <!--通過 = 按鈕來調用創建的函數,得到結果--><input type='text' id='fruit'/></body></html>
查看完整描述

1 回答

?
落葉1111

TA貢獻57條經驗 獲得超9個贊

沒寫入口函數

查看完整回答
反對 回復 2017-05-14
  • 1 回答
  • 0 關注
  • 1673 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號