So what is the jQuery most first function? It is an onload function. What does it mean? Let start from beginning. You need to understand how javascript work. Javascript is a scripting language which is used to manipulate html elements of the page. It can interact with the elements which are already part of the page or it can even insert or remove additional elements from the page. If we want to execute the javascript commands we need to be sure that the page has already finished loading so we do not try to interact with elements which has not been loaded yet. That is why we need function which takes care of all this for us. jQuery onload function can do just that. It makes sure that the page (actually DOM – Document Object Model) has been fully loaded so our javascript “commands” can fire safely.
$(function(){
// All your functions will come in here
});
Is it that simple? Yes it is!
Lets do simple example.
$(function(){
// so we said that everything we put in here will be executed after the DOM finished loading
// lets do the simplest function alert
alert("hello world");
// if you use Firebug (very important Firefox extension) you will find very useful to print stuff into its console, this is how you do it
console.log("hello console");
});