如何写一个显示年份的下拉框
1个回答
2017-07-31
展开全部
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Jay 跨锐</title>
<style type="text/css">
</style>
<script type="text/javascript">
onload = function ()
{
var sel = document.getElementById ('sel');
for ( var i = 1970; i < 2015; i++)
{
var option = document.createElement ('option');
option.value = i;
var txt = document.createTextNode (i);
option.appendChild (txt);
sel.appendChild (option);
}
}
</script>
</head>
<body>
<select id="sel">
</select>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title>Jay 跨锐</title>
<style type="text/css">
</style>
<script type="text/javascript">
onload = function ()
{
var sel = document.getElementById ('sel');
for ( var i = 1970; i < 2015; i++)
{
var option = document.createElement ('option');
option.value = i;
var txt = document.createTextNode (i);
option.appendChild (txt);
sel.appendChild (option);
}
}
</script>
</head>
<body>
<select id="sel">
</select>
</body>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询