js計(jì)算兩個(gè)數(shù)相加 javascript中多個(gè)變量相加,咋寫?
javascript中多個(gè)變量相加,咋寫?可以寫成網(wǎng)頁文件a.html,內(nèi)容如下。用瀏覽器打開a.html,頁面將顯示結(jié)果:4(瀏覽器應(yīng)允許運(yùn)行JavaScript)<HTML><BODY
javascript中多個(gè)變量相加,咋寫?
可以寫成網(wǎng)頁文件a.html,內(nèi)容如下。用瀏覽器打開a.html,頁面將顯示結(jié)果:4(瀏覽器應(yīng)允許運(yùn)行JavaScript)<HTML><BODY><script> var shouji=1,benzi=1,danao=1,dandanan=1 var toltol=shouji benzi danaodandandocument.write文件(toltol)</script></body></HTML>當(dāng)然,文檔.寫入(托爾)罐也可以寫為alert(TOL),并顯示一個(gè)信息窗口。如果你想輸入a,B,C,D數(shù)據(jù)并做四個(gè)算術(shù)運(yùn)算,您可以使用類似于以下的方法:<html><body><input type=“var”id=“a”> a&Ltbr><input type=“var”id=“B”> B&Ltbr><input type=“var”id=“C”> C&Ltbr><input type=“var”id=“d”&Ltbr><input type=“button”onclick=“calculate()”value=“calc”><script>函數(shù)calculate(){var a=文檔.getElementById(“A”)。valuevar b=文檔.getElementById(“B”)。valuevar c=文檔.getElementById(“C”)。valuevar d=文檔.getElementById(“D”).valuevar e=a*D b*D c*dalert(e)}</script></body></HTML>