During publishing of my book, Smashing jQuery it seems as though some errors have been introduced. The following is a list of the errors which I have spotted, if you find other errors, please fill out this form and I will make sure they get added to this list.

Page 32

The following code is incorrect:

[js]
<script type="text/javascript"></>
[/js]

It should be changed to:

[js]
<script type="text/javascript">
[/js]

Page 33

The code block below shows up twice on the bottom of the page, it should only be there once.

[js]
$(window).load {
//jQuery Code Goes Here
alert("This window has been loaded.");
});

$(window).load {
//jQuery Code Goes Here
alert("This window has been loaded.");
});
[/js]

Page 40

The following code is incorrect:

[js]
$(selector).method().
[/js]

It should be changed to:

[js]
$(selector).method();
[/js]

Page 51

The following code is incorrect:

[js]
$(‘.book-one, .book-two, .book-three, .book-four, .book-five, #header, #footer p’).css(‘background’’’,’#ccc’’’);
[/js]

It should be changed to:

[js]
$(‘.book-one, .book-two, .book-three, .book-four, .book-five, #header, #footer p’).css(‘background’,’#ccc’);
[/js]

Page 57

The following code is incorrect:

[js]
$(‘.content:has(p)’).css(‘font-size’’’,’18px’’’);
[/js]

It should be changed to:

[js]
$(‘.content:has(p)’).css(‘font-size’,’18px’);
[/js]

Page 58

The following code is incorrect:

[js]
$(‘.error:empty)’).css(‘display’,’none’);[/js]

It should be changed to:

[js]
$(‘.error:empty’).css(‘display’,’none’);[/js]

Page 76

The code block below shows up twice on the bottom of the page, it should only be there once.

[js]
$(window).bind(‘unload’, function() {
alert(‘You have not finished filling out the form. Are you sure you want to leave?’);
}
[/js]

Page 77

The code block below shows up twice on the bottom of the page, it should only be there once.

[js]
$(window).unload(function() {
alert(‘You have not finished filling out the form. Are you sure you want to leave?’);
}
[/js]

Page 78, 79

The code block below is missing single or double quotes around the click event handler.
The following code is incorrect:

[js]
$(document).ready(function() {
$(‘.mylink’).bind(click, alertMe)
}
[/js]

It should be changed to:

[js]
$(document).ready(function() {
$(‘.mylink’).bind(‘click’, alertMe)
}
[/js]

Page 123

On step 7:

[js]var slideText [/js]

should be:

[js]var slideNum [/js]

On step 9:

[js]var slideText [/js]

should be:

[js]var slideNum [/js]

On step 9:
Anywhere slideText is referenced it should be replaced with slideNum

Page 126

On step 18:

[js]$(‘#nav li a’).bind(‘click’, function(){
$(‘#nav li a’).removeClass(‘active’);
$(this).addClass(‘active’);

$(".slide-text").css({
‘top’:’-100px’,
‘right’:’0px’,
});

$(".slide-text").stop();
$(".slide-text").clearQueue();

var active = $(‘#nav li a.active’).attr("rel") – 1;
var slidePos = active * slideWidth;
var slideNum = $(‘#nav li a.active’).attr("rel");

$(".slides-container").animate({
left: -slidePos,
},1000, function(){
$(‘.slide-text’).addClass(‘textStrip’});
});
[/js]

should be:

[js]$(‘#nav li a’).bind(‘click’, function(){
$(‘#nav li a’).removeClass(‘active’);
$(this).addClass(‘active’);

$(".slide-text").css({
‘top’:’-100px’,
‘right’:’0px’,
});

$(".slide-text").stop();
$(".slide-text").clearQueue();

var active = $(‘#nav li a.active’).attr("rel") – 1;
var slidePos = active * slideWidth;
var slideNum = $(‘#nav li a.active’).attr("rel");

$(".slides-container").animate({
left: -slidePos,
},1000, function(){
$(‘.slide-text’).addClass(‘textStrip’});
});
});
[/js]

Page 189

On step 5:

[js]
$(‘#status’).bind({
keypress : function() {
var inputText = $(this).val();
var numChar = inputText.length;
var charRemain = numChar – maxNum;
if (numChar <= maxNum) {
$(‘.counter’).text(charRemain);
}
});
});
[/js]

should be:

[js]
$(‘#status’).bind({
keypress : function() {
var inputText = $(this).val();
var numChar = inputText.length;
var charRemain = numChar – maxNum;
if (numChar <= maxNum) {
$(‘.counter’).text(charRemain);
}
}
});
[/js]

Page 189

On step 7:

[js]
$(‘#status’).bind({
keypress : function() {
var inputText = $(this).val();
var numChar = inputText.length;
var charRemain = numChar – maxNum;
if (numChar <= maxNum) {
$(‘.counter’).text(charRemain);
}
else if (numChar > maxNum){
event.preventDefault();
}
});
});
[/js]

should be:

[js]
$(‘#status’).bind({
keypress : function() {
var inputText = $(this).val();
var numChar = inputText.length;
var charRemain = numChar – maxNum;
if (numChar <= maxNum) {
$(‘.counter’).text(charRemain);
}
else if (numChar > maxNum){
event.preventDefault();
}
}
});
[/js]

Page 268

On step 3:

[js]
<label>Date</label>
<input type="text" id="date" />
</div>

[/js]

should be:

[js]
<label>Date</label>
<input type="text" id="date" />
[/js]

1 thought on “Smashing jQuery Errata”

Bill S. · May 11, 2014 at 2:04 pm

What about “Smashing jQuery,” p. 240… URL for the variable var query = “http://feeds.delicious.com/v2/json/jakerutter?count=10” evidently has aged out ;-(
I’d really like to see this work; will search for other jsonp sites in the meantime.

Leave a Reply

Your email address will not be published. Required fields are marked *