jQuery Cookbook

Errata for jQuery Cookbook

Submit your own errata for this product.


The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color Key: Serious Technical Mistake Minor Technical Mistake Language or formatting error Typo Question Note Update



Version Location Description Submitted By Date Submitted Date Corrected
Printed
Page 11
1st line, Section header

Section 2.1 contains a typo. It reads: 1.2 Executing jQuery/JavaScript !Coded! after the DOM has Loaded but Before Complete Page Load Should be: 1.2 Executing jQuery/JavaScript !Code! after the DOM has Loaded but Before Complete Page Load

Note from the Author or Editor:
1.2 Section Header: "Coded" should be "Code"

Andrey Esaulov  Dec 11, 2009 
Printed
Page 16
Code snippet at the top of the page.

"8 inputs" should read "selected 8 inputs" //"4 inputs" should be //"selected 4 inputs" as long as the next line is corrected to: alert('selected ' + jQuery ... [notice the space after "selected"] //"12 inputs" should be //"selected 12 inputs" as long as the next line is corected to: alert('selected ' + jQuery ... [notice the space after "selected"]

Note from the Author or Editor:
Corrections to the code example: Where the comments in the code say "8 inputs", "4 inputs", and "12 inputs" it should say "selected 8 inputs", "selected 4 inputs", and "selected 12 inputs". In the code itself, the sections for 4 inputs and 12 inputs both need a space after selected, inside the quotes, like alert('selected ' Corrected code: //searches within all form elements, using a wrapper for context, alerts "selected 8 inputs" alert('selected ' + jQuery('input',$('form')).length + ' inputs'); //search with the first form element, using DOM reference as the context, alerts //"selected 4 inputs" alert('selected ' + jQuery('input',document.forms[0]).length + ' inputs'); //search within the body element for all input elements using an expression, //alerts "selected 12 inputs" alert('selected ' + jQuery('input','body').length + ' inputs');

Robert Meineke  Dec 29, 2009 
PDF, Safari Books Online
Page 16
code, last line

A unmatched </li> tag is present on the last line of the code. Probably this can also be a typo.

Note from the Author or Editor:
In the code example in section 1.5, line 13 of the code: &lt;a href="#"&gt;&lt;/a&gt;&lt;/li&gt; Should be: &lt;a href="#"&gt;&lt;/a&gt;

Dragos Crintea  Sep 19, 2010 
Printed
Page 18
code example

alert() text states "italic words", what is returned is the number of italic elements, <em>, that exist within the HTML document.

Note from the Author or Editor:
Because &lt;em&gt; tags could be wrapping groups of words, "italic words" in the code samples should be changed to "italic elements" or "italic sections". This change should be made in three places: at the end of the code sample on page 18 and in the two short code samples at the top of 19.

Chris Pieper  Nov 28, 2010 
Printed
Page 30
1.14, end of 'Solution' section

The line reads: like to remove (e.g., jQuery('a')removeAttr('title')). It should read: like to remove (e.g., jQuery('a').removeAttr('title')).

Note from the Author or Editor:
"." missing before removeAttr

ssalter42  Sep 20, 2010 
Printed, PDF
Page 50-51
2.12

on page 50 we create the following code to add data to a span: jQuery('span').data('something', 123); on page 51 after creating the filter(:data) there are some suggestions how to use the filter: jQuery('div:data("something",123)'); jQuery('div:data(something)'); jQuery('div:data(something, "something else")'); in all cases It has to be "span" instead of "div".

Note from the Author or Editor:
On page 51, the three code examples in the middle should be jQuery('span:data("something",123)'); jQuery('span:data(something)'); jQuery('span:data(something, "something else")');

Anonymous  May 09, 2011 
Printed
Page 63
Figure 3-5

Figure 3-5 is incorrect. It is in section 3.4 but illustrates the problem described in section 3.5. Note that it is nearly identical to the next figure, Figure 3-6 on page 66. Both have the heading "Chapter 3 - Recipe 5 - Make a unique array of values from an existing array".

Joseph R. Rizzo Jr.  Feb 18, 2010 
Printed
Page 63
Figure

Figure 3-5 is a duplicate of figure 3-6 on page 66, and contains the output for recipe 3.5 rather than that for recipe 3.4. There is no figure corresponding to recipe 3.4.

Anonymous  Aug 24, 2010 
Printed
Page 66
Figure 3-6

Figure 3-6 does not match html on page 65

Note from the Author or Editor:
It looks like Figure 3-5 should go with Example 3.5 and Figure 3.6 is an out of date duplicate. Example 3.4 appears to have no corresponding figure.

Anonymous  Dec 19, 2009 
Printed
Page 107
Bottom page's code sample

if you refer to examples listed in top of page 108 (with .clientX ), it seems to me that the code in page 107 should have class="clientX" instead of id="clientX"

Note from the Author or Editor:
Yes, clientX should be a class, not an id, so: <table id="log"> <tr><td>Client X:</td><td id="clientX"></td></tr> ... </table> Should be: <table id="log"> <tr><td>Client X:</td><td class="clientX"></td></tr> ... </table>

Lionel  Apr 28, 2010 
Printed
Page 119
First, Second, and Last Code Examples

In several code examples on page 119 (and continued in the same example on page 120), the HTML has a span with the class of "baz", but in the code it many times looks for the class "bar".

Note from the Author or Editor:
In the Problem: <span class="baz" style="display:none;"> Should be: <span class="bar" style="display:none;"> And in the Solution, one instance of baz: $('.foo').css({ fontSize: '18px' }).find('.baz').show(); Should be: $('.foo').css({ fontSize: '18px' }).find('.bar').show();

Camoy  Dec 11, 2010 
Printed
Page 137
Figure 6-2

[Zeevro is on the right track here.] But in this particular figure the outermost layer (read: the darkest grey] should be labeled "border" as outerHeight includes the border and the padding. What had me stumped is the solid black line between the 'inner' padding and the 'outer' padding. It looked to me like the solid black line was the border when I think it is intended to be the separation between the padding and the border. Maybe a dotted line (or no line at all) would have been a better choice here.

Robert Meineke  Dec 29, 2009 
Printed
Page 137
Figure 6-2

The illustration in figure 6-2 on page 137 is inaccurate. It repeats the label "padding" twice. The outer "padding" should read "border". (Note others here have also noticed the mistake, but have incorrectly asserted it should read "margin". The margin is not relevant to this example. If it were included, it would appear outside the outermost edge of the illustration. The second "padding" label definitely should read "border".)

Chris Weekly  May 25, 2010 
PDF
Page 149
Solution1, Chapter 6.9

Change jQuery('body').removeClass('large small').addClass(size); to $body.removeClass('large small').addClass(size);

Zeevro  Dec 05, 2009 
PDF
Page 153
1st example code block in Chapter 7.1

Change $(document).ready(function () { $('#animate').click(function () { $('.box').show(); }); ); to $(document).ready(function () { $('#animate').click(function () { $('.box').show(); }); }); The anonymous function inside the ready method had no closing curly bracket.

Zeevro  Dec 05, 2009 
Printed
Page 153
6th line from the bottom, end of ready(function)

the end of the function is ); as it should be }); with the curly brace lionel

lionel  Apr 30, 2010 
PDF
Page 173
1st example

The example is as follows: jQuery('div').bind'click keydown', function(e){ alert('event'); }); However, it needs to be: jQuery('div').bind('click keydown', function(e){ alert('event'); }); Notice the inserted parenthesis after "bind".

Note from the Author or Editor:
Yes, insert open paren between bind and 'click.

Anonymous  Feb 22, 2010 
Printed
Page 184
last paragraph

The book says $parent = jQuery(this).parents(); It should be $parents = jQuery(this).parents(); because next line is using $parents.

Neeraj  Dec 22, 2009 
Printed
Page 217
first sentence of "Discussion" section

The paragraph begins: "The jQuery .sibling() method . . ." The method is siblings() with an "S", not sibling().

Note from the Author or Editor:
The first sentence of the discussion should begin: "The jQuery .siblings() method . . ."

wiseguy316  Aug 03, 2010 
PDF
Page 276
2nd code sample

The 2nd static function call should be: jQuery.pulse.warpspeed(jQuery('p:first'));

Eito Katagiri  Aug 23, 2011 
PDF
Page 392
4th code block

Under "Discussion," in the third paragraph, last sentence it says..."For example, if you’re expecting the server to return XML, then a value of xml would be appropriate" but the code listing has: dataType: 'html', when it should read 'xml' or the copy should be changed.

Note from the Author or Editor:
Yes, it would make since to change the text to match the example. "For example, if you’re expecting the server to return XML, then a value of xml would be appropriate" Could be: "For example, if you’re expecting the server to return HTML, then a value of html would be appropriate"

Anonymous  Jan 04, 2011