1
這裏就選擇選項循環是我的代碼:使用JavaScript的
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
但我:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Date Picker</title>
</head>
<body>
<p>Click the button to loop through a block of code five times.</p>
<button onclick="myFunction()">Try it</button>
<select id="demo">
</select>
<p id="demo"></p>
<script>
function myFunction()
{
var i;
for (i=1;i<=5;i++){
document.getElementById("demo").innerHTML="<option value="+i+">"+i+"</option>";
}
}
</script>
</body>
</html>
所有我想,當我按下按鈕,下拉框中會產生這樣一個選項是隻能得到這個代碼
<option value="5">5</option>
它只顯示5的選項。請幫助..謝謝