lurning too koad
lurning too koad

Reputation: 2974

JQuery: how to preface a script within the body?

    <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

Answers (1)

Anonymous
Anonymous

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

Related Questions