I need to check if some JS is supported on a device (desktop browser or mobile, so various devices). If it is then I want to perform various further actions. Below sets a date select calendar, and I was hoping the if( $(‘#test’).datepicker ) {} part would check if it is supported, but sometimes it fires even though it isn;t supported.
What’s the best way to check if the calendar will actually work?
if (datefield.type!="date"){ //if browser doesn't support input type="date"
jQuery(function($){ //on document.ready
$('#test').datepicker({ dateFormat: 'dd/mm/yy' });
if( $('#test').datepicker ) {
alert("it works!");
}
})
}
The code is from this: http://docs.jquery.com/UI/Datepicker
Thanks.