1、 jQuery UI Datepicker(加上周选择扩展)
<link rel=”stylesheet” href=”https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css”>
<script src=”https://code.jquery.com/jquery-3.6.0.min.js”></script>
<script src=”https://code.jquery.com/ui/1.12.1/jquery-ui.min.js”></script>
<input type=”text” id=”datepicker”>
<script>
$(function() {
$(“#datepicker”).datepicker({
beforeShowDay: function(date) {
var day = date.getDay(); // 获取当前日期是星期几(0-6,0为周日,1为周一,…)
return [day === 1, “”]; // 只允许选择星期一,其他日期不可选
},
showWeek: true, // 显示周数
firstDay: 1, // 设置一周的开始为星期一
dateFormat: ‘yy-mm-dd’ // 日期格式
});
});
</script>