Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Jquery all code under $(document).ready(function() Re: Jquery all code under $(document).ready(function()

#64864
BryantAXS
Member

Yes you can do that. You might want to look into making your code a little more "object oriented" by breaking up specific tasks into objects. For example you could do:

Code:
var animation = function(){
//animation code
}

var slider = function(){
//slider code
}

var accordion = function(){
//accordion code
}

var highlight = function(){
//highlight code
}

$(document).ready(function(){

var animationObj = new animation();
var sliderObj = new slider();
var accordionObj = new accordion();
var highlightObj = new highlight();

})

This will better organize your code and as you start to develop more advanced scripts it will help you make your code run more efficiently.