I created an HTML webpage that includes some JavaScript code to enhance the user experience. However, I encountered an issue when trying to incorporate a load JavaScript function alongside the scroll JavaScript function on my page.
The load script is positioned right under the body tag. I experimented with moving the scroll script both within the head tag and the body tag, but it seems that the scroll script fails to work regardless of its placement.
As an example, here is the scroll script:
<script type="text/javascript">
$(document).ready(function(){
$("a").on('click', function(event) {
if (this.hash !== "") {
event.preventDefault();
var hash = this.hash;
$('html, body').animate({
scrollTop: $(hash).offset().top
}, 600, function(){
window.location.hash = hash;
});
}
});
});
</script>
Here is the load script being used:
<div class="se-pre-con"></div>
<script type="text/javascript">
$(window).load(function() {
$(".se-pre-con").fadeOut("slow");;
});
</script>