Window.onload reported an error

datepicker can be executed at $(document). Ready but error is reported in window.onload ()

Uncaught TypeError: $(.). Datepicker is not a function

related codes

< script type= "text/javascript" >
$(document) .ready (function () {
alert ("document");
$("- sharpdate"). Datepicker ({

)
    yearRange: "-70:+0" 

});

});

window.onload= function () {
alert ("window")
$("- sharpdate"). Datepicker ({

)
    yearRange: "-70:+0" 

});

}
< / script >

what result do you expect? What is the error message actually seen?

Apr.07,2021

In the

window.onload version of your own demo, you must have put the jquery library at the end of the entire html. The code that assigns the onload is written before the jquery is loaded.

it won't be a problem to put the code that introduces jQuery before window.onload.

Menu