<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
window.onload = function() {
var obj = document.getElementById("sel");
var endYear = new Date().getYear() + 1910;
var date = new Date().getYear() + 1900; //当前年份
for (var i = date - 10; i < endYear; i++) {
var op = new Option(i, i);
obj.add(op);
}
obj.options[obj.options.length - 10].selected = 1; //设置当前年份为默认值
};
$(function() {
$('#sel').change(function() {
var zhi = $(this).val();
alert(zhi);
});
});
</script>
</head>
<body>
<select id="sel"></select>
</body>
</html>
js下拉框时间拼接
猜你喜欢
转载自blog.csdn.net/qq_36521848/article/details/79448126
今日推荐
周排行