Home › Forums › JavaScript › Jquery all code under $(document).ready(function() › Re: Jquery all code under $(document).ready(function()
September 30, 2009 at 12:04 pm
#64864
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
}
//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.