I am new with JQuery, I have a problem. I used jQuery datepicker. When I first open the my site the datepicker open as well. However in my function I specificaly used onSelect function but still see them initially. How can I prevent this from happening? I tried using the below code. First, it shows the datepicker, then hides it but now can't open it on select.
$('#datepicker').datepicker('show') // to hide when open the site
$('#datepicker').datepicker('hide')
This is my original code. :
$( function() {
var days = ['Pazar','Pazartesi', 'Salı', 'Çarşamba', 'Perşembe', 'Cuma', 'Cumartesi'];
$('#datepicker2').datepicker({
dateFormat: 'dd M, yy',
language: 'tr',
onSelect: function () {
var date = $(this).datepicker('getDate' ,true);
var day = date.getDay();
console.log(days[day]);
console.log(day);
$( "#day2" ).html( days[day] );
}
});
$("#datepicker2").datepicker().datepicker("setDate", new Date());
var day = $('#datepicker2').datepicker('getDate').getDay();
$( "#day2" ).html( days[day] );
});
I have to datepicker btw one is called datepicker the other one is datepicker2
<div class="input-wrapper">
<i class="far fa-calendar-alt"></i>
<input id="datepicker">
<span id='day'></span>
</div>