If you go to jquery.com they have some great introduction docs for
learning jQuery. However you can start by reading this email :p
Typically developers load javascript between the <header> tags. The
problem with doing this is that the browser may (or will) activate the
script before the page is completely loaded. Why is this a problem?
Because your script may be trying to access parts of the html page
(aka - DOM). If the page isn't fully loaded then the browser maybe
get confused on how to handle your script.
Thankfully the jQuery library provided a simple (but not exclusive)
way to prevent such a problem from occurring. And thus we have the -
Dom Ready Function
$(document).ready(function () {
$("p").text("The DOM is now loaded and can be manipulated.");
});
jQuery is all about making javascript FUN! So I guess some of the
developers felt the the $(document.ready(function(){}); was a too long
of an api. Considering that it's used in just about everything you do
with jquery. So they put together a shortcut method -
$(function(){
// Ta DA!!!
});
One thing that help me understand jquery is that EVERYTHING is a
function. And it's ok to have functions inside of functions... in time
you'll get use to it.
Good luck,
Cheers : )
On Jun 9, 2009, at 12:19 AM, wangsuya wrote:
Hi everyone
Know I try to study javascript using jQuery code,but first I do not
know why jQuery start with (function(){....
What is "(" function? Why using (function(){
start jQuery? Thanks in advance.
Wang Suya