Reputation: 2974
<script>
/* set #splash-bg height */
$(window).on('load',function(){
var splashbgHeight = $("#meat").css("top");
$("#splash-bg").css("height",splashbgHeight);
$(window).resize(function(){
var splashbgHeight = $("#meat").css("top");
$("#splash-bg").css("height",splashbgHeight);
});
});
</script>
I have this script in an HTML document in the body tag. Must I preface it with $( document ).ready() or something of the sort?
Upvotes: 1
Views: 44
Reputation: 1990
If you want all events in jquery to execute after DOM has loaded then use:
$(document).ready(function(){//your code here})
Upvotes: 2