課程
/前端開發
/JavaScript
/JavaScript進階篇
var myage =document.getElementById("div1").value;
這里面的value是指什么意思?
請求高手解答。
2015-07-13
源自:JavaScript進階篇 4-3
正在回答
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>if...else</title>
<script type="text/JavaScript">
function age(){
var myage =document.getElementById("div1").value;//獲得text的值
if(myage<=44)
? {document.write("青年");}
else if(myage<=59)?
? {document.write("中年人");}
else if ?(myage<=89)
? {document.write("老年人");}
else ? ? ? ?
? {document.write("長壽老年人");}
}
</script>
</head>
<body>
<input id="div1" type="text" name="grade"></br>
<input type="button" value="還是小伙子?" onclick="age()">
</body>
</html>
獲取id為div1的值,并把它賦值給myage。value是值得意思
值。就是說:ID為div1的值
幾米_陽光 提問者
淺水了 回復 幾米_陽光 提問者
屬性value的值
舉報
本課程從如何插入JS代碼開始,帶您進入網頁動態交互世界
2 回答這里的取值用var = document.getElementById(“id”).value
1 回答獲取下拉框的值document.getElementById().value和document.getElementById().options[document.getElementById().selectedIndex].value有什么區別嗎?
2 回答var s=document.getElementById('select').value;
3 回答var j= document.getElementById("wb").value
3 回答var oSlt = document.getElementById("select").value;
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2018-04-22
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>if...else</title>
<script type="text/JavaScript">
function age(){
var myage =document.getElementById("div1").value;//獲得text的值
if(myage<=44)
? {document.write("青年");}
else if(myage<=59)?
? {document.write("中年人");}
else if ?(myage<=89)
? {document.write("老年人");}
else ? ? ? ?
? {document.write("長壽老年人");}
}
</script>
</head>
<body>
<input id="div1" type="text" name="grade"></br>
<input type="button" value="還是小伙子?" onclick="age()">
</body>
</html>
2015-11-25
獲取id為div1的值,并把它賦值給myage。value是值得意思
2015-07-14
值。就是說:ID為div1的值
2015-07-14
屬性value的值