-
Book Overview & Buying
-
Table Of Contents
Learning jQuery - Fourth Edition - Fourth Edition
The methods we have seen throughout the jQuery library often take at least one function as a parameter. For convenience, we often use anonymous functions so that we can define the function behavior right when it is needed. This means that functions are rarely in the top-level namespace; they are usually inner functions, which means they can quite easily create closures.
Nearly all the code we write using jQuery ends up getting placed inside a function passed as an argument to $(document).ready(). We do this to guarantee that the DOM has loaded before the code is run, which is usually a requirement for interesting jQuery code. When a function is created and passed to .ready(), a reference to the function is stored as part of the global jQuery object. This reference is then called at a later time when the DOM is ready.
We usually place the $(document).ready() construct at the top level of the code structure, so this function...
Change the font size
Change margin width
Change background colour