I've built a HTML webpage with some JavaScript code for a smooth user experience. However, the scroll JavaScript function does not work anymore if I add the load JavaScript function to my webpage.
The load script is just below the body tag. I've tried placing the scroll script inside the head tag and in the body tag but doesn't seem to work anywhere is the scroll script present.
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>
Load script:
<div class="se-pre-con"></div>
<script type="text/javascript">
$(window).load(function() {
$(".se-pre-con").fadeOut("slow");;
});
</script>