I am working on a web page that pulls an external javascript file that has all of my functions in it. I’ll call that file “functions.js”.
functions.js has a jQuery has a $(function(){...}); to do my operations when the page is ready. My question is, is it possible to also write another $(function(){...} on the body of the same page that calls functions.js, so that whatever I do in both of the domReady functions happens on the page? For example, if functions.js is:
$(function(){
$('div').css('color','green');
}
and I put this code in tags on the page which calls functions.js:
$(function(){
$('div').css('background-color','red');
}
will the page end up making my divs have both green text AND red backgrounds, or will one override the other, or will neither work?
I hope this makes sense!
Yes, you can add as many $(document).ready() calls as you want: http://docs.jquery.com/Tutorials:Multiple_$(document).ready()