问题
My calendar code:
<script>
$(document).ready(function() {
var events = <?php echo json_encode($data) ?>;
$('#calendar').fullCalendar({
header: {
left: 'prev,next',
center: 'title',
right: ''
},
defaultDate: new Date(),
// can click day/week names to navigate views
editable: true,
eventLimit: true,
droppable: true, // allow "more" link when too many events
dayClick: function(date, jsEvent, view) {
$("#successModal").modal("show");
$("#eventDate").val(date.format());
},
events : events
});
});
</script>
view page code:
<div id='calendar'></div></div>
These are the code how to select a week in this calendar using js. i have tired using some code but it is not working well
回答1:
This may help you to select whole week in calendar using jQuery
HTML
<div class="row">
<div class="col-lg-2">
<input type="week" value="@week" class="form-control" id="Week" />
</div>
</div>
CSS
/* Week picker */
.datepicker-days > table > tbody > tr:hover {
background-color: #808080;
}
JavaScript
$(document).ready(function () {
// Add weekpicker
$('#Week').datepicker({
calendarWeeks: true,
weekStart: 1
});
});
$('#Week').on('changeDate', function (e) {
var value = $("#Week").val();
var year = moment().format('YYYY');
var week = moment(e.date).format('WW');
$("#Week").val(year + '-W' + week);
});
来源:https://stackoverflow.com/questions/60574852/how-to-select-a-week-in-calendar-using-js