📅  最后修改于: 2023-12-03 14:43:11.847000             🧑  作者: Mango
The firstDay
option in the jQuery UI Datepicker determines the first day of the week in the date picker calendar.
$( ".selector" ).datepicker({ firstDay: 0 });
The "firstDay" option takes an integer value between 0 and 6, where 0 represents Sunday, 1 represents Monday, and so on. The default value is 0, which means that Sunday is the first day of the week.
$( ".selector" ).datepicker({ firstDay: 1 });
The above code sets Monday as the first day of the week.
Here is an example where the firstDay
option is set to 1, to make Monday the first day of the week:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>jQuery UI Datepicker - First Day Option Example</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.12.4.js"></script>
<script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
$( "#datepicker" ).datepicker({ firstDay: 1 });
} );
</script>
</head>
<body>
<p>Date: <input type="text" id="datepicker"></p>
</body>
</html>
In conclusion, the firstDay
option in the jQuery UI Datepicker allows the programmer to specify which day should be the first day of the week. This option can be useful in situations where the default first day (Sunday) is not suitable or desired.