With JQuery <= 2.x, this code worked, displaying the text in the div
after everything had loaded:
<!DOCTYPE html>
<html>
<head>
<title>JQuery 3 Window onload test</title>
</head>
<body>
<div id="my_div" style="visibility:hidden">Greetings!</div>
<script src="jquery.js"></script>
<script>
$(function () {
$(window).on('load', function () {
$('#my_div').css('visibility', 'visible');
});
});
</script>
</body>
</html>
With the new JQuery 3.0.0, the div is not displayed. However, if I remove the window onload condition altogether, like this:
$(function () {
$('#my_div').css('visibility', 'visible');
});
...then it works, or if I move the window onload outside the document ready like this:
$(function () {
// other things I need to do once the document is ready
});
$(window).on('load', function () {
$('#my_div').css('visibility', 'visible');
});
...then it also works. There is documentation that apparently is addressing what's happening in my example here, at the JQuery migration/upgrade info page.
Clarification from JQuery gurus would be appreciated, as I now need to revise many files to accommodate this behavior, and want to do it the correct way with the expected behavior occurring as in the past. Many thanks!