SlideShare a Scribd company logo
Visit https://ebookultra.com to download the full version and
explore more ebooks or textbooks
Beginning JavaScript und CSS development with
jQuery 1. ed Edition Richard York
_____ Click the link below to download _____
https://ebookultra.com/download/beginning-javascript-und-
css-development-with-jquery-1-ed-edition-richard-york/
Explore and download more ebooks or textbooks at ebookultra.com
Here are some recommended products that we believe you will be
interested in. You can click the link to download.
Beginning CSS Cascading Style Sheets for Web Design Wrox
Beginning Guides 2nd Edition Richard York
https://ebookultra.com/download/beginning-css-cascading-style-sheets-
for-web-design-wrox-beginning-guides-2nd-edition-richard-york/
Joomla 1 5 JavaScript jQuery 1st Edition Jose Argudo
Blanco
https://ebookultra.com/download/joomla-1-5-javascript-jquery-1st-
edition-jose-argudo-blanco/
Beginning JavaScript 3rd ed Edition Paul Wilton
https://ebookultra.com/download/beginning-javascript-3rd-ed-edition-
paul-wilton/
Professional XMPP Programming with JavaScript and jQuery
1st Edition Jack Moffitt
https://ebookultra.com/download/professional-xmpp-programming-with-
javascript-and-jquery-1st-edition-jack-moffitt/
Beginning Windows Store Application Development HTML and
JavaScript Edition Scott Isaacs
https://ebookultra.com/download/beginning-windows-store-application-
development-html-and-javascript-edition-scott-isaacs/
Html 5 Black Book Covers Css 3 Javascript Xml Xhtml Ajax
Php And Jquery 2Ed 2nd Edition Dt Editorial Services
https://ebookultra.com/download/html-5-black-book-covers-
css-3-javascript-xml-xhtml-ajax-php-and-jquery-2ed-2nd-edition-dt-
editorial-services/
jQuery and JavaScript Phrasebook 1st Edition Brad Dayley
https://ebookultra.com/download/jquery-and-javascript-phrasebook-1st-
edition-brad-dayley/
Drupal 6 JavaScript and jQuery 1st Edition Matt Butcher
https://ebookultra.com/download/drupal-6-javascript-and-jquery-1st-
edition-matt-butcher/
Beginning JavaScript 5th Edition Jeremy Mcpeak
https://ebookultra.com/download/beginning-javascript-5th-edition-
jeremy-mcpeak/
Beginning JavaScript und CSS development with jQuery 1. ed Edition Richard York
Beginning JavaScript und CSS development with jQuery
1. ed Edition Richard York Digital Instant Download
Author(s): Richard York
ISBN(s): 9780470227794, 0470227796
Edition: 1. ed
File Details: PDF, 7.18 MB
Year: 2009
Language: english
Beginning
JavaScript®and CSS Development with jQuery
Richard York
27794ffirs.indd 5 3/16/09 3:14:20 PM
Beginning JavaScript® and CSS Development with jQuery
Published by
Wiley Publishing, Inc.
10475 Crosspoint Boulevard
Indianapolis, IN 46256
www.wiley.com
Copyright © 2009 by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 978-0-470-22779-4
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
Library of Congress Cataloging-in-Publication Data
York, Richard.
Beginning JavaScript and CSS development with jQuery / Richard York.
p. cm.
Includes index.
ISBN 978-0-470-22779-4 (paper/website)
1. JavaScript (Computer program language) 2. Web sites--Design. 3. Cascading style sheets. I. Title.
QA76.73.J38Y67 2009
006.7’6--dc22
2009005636
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means,
electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108
of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization
through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA
01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Permissions
Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at
http://www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with
respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including
without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or pro-
motional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold
with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If
professional assistance is required, the services of a competent professional person should be sought. Neither the publisher
nor the author shall be liable for damages arising herefrom. The fact that an organization or Web site is referred to in this
work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses
the information the organization or Web site may provide or recommendations it may make. Further, readers should be
aware that Internet Web sites listed in this work may have changed or disappeared between when this work was written
and when it is read.
For general information on our other products and services please contact our Customer Care Department within the
United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Programmer to Programmer, and related trade dress are trade-
marks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries,
and may not be used without written permission. JavaScript is a registered trademark of Sun Microsystems, Inc. All other
trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or vendor
mentioned in this book.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in
electronic books.
27794ffirs.indd 6 3/16/09 3:14:20 PM
Contents
Introduction xix
Part I: jQuery API 1
Chapter 1: Introduction to jQuery 3
What Does jQuery Do for Me? 4
Who Develops jQuery? 5
Obtaining jQuery 5
Installing jQuery 5
Programming Conventions 8
XHTML and CSS Conventions 9
JavaScript Conventions 16
Summary 25
Chapter 2: Selecting and Filtering 27
The Origin of the Selectors API 28
Using the Selectors API 29
Filtering a Selection 37
Searching within a Selection with find() 38
Finding an Element’s Siblings with siblings() 39
Selecting Specific Siblings 42
Searching Ancestors Using the parents() and parent() Methods 46
Selecting Children Elements 48
Selecting Elements via What You Don’t Want 50
Selecting a Snippet of the Results 51
Adding More Elements to a Selection 53
Selecting One Specific Element from a Result Set 55
Summary 66
Exercises 66
Chapter 3: Events 69
Assigning an Event with the Traditional Event Model 69
Assigning Events with the W3C Event Model 72
The this Object 73
The event Object 75
xii
Contents
The Microsoft JScript Event Model 77
Creating a Universal Event API 78
Binding Events with jQuery’s bind() Method 80
Binding Events with jQuery’s Event Methods 82
Triggering Events 83
Summary 93
Exercises 93
Chapter 4: Manipulating Content and Attributes 95
Setting and Accessing Attributes 95
Manipulating Class Names 105
Manipulating HTML and Text Content 109
Getting, Setting, and Removing Content 110
Appending and Prepending Content 115
Inserting Beside Content 123
Inserting Beside Content via a Selection 125
Wrapping Content 129
Replacing Elements 146
Removing Content 150
Cloning Content 154
Summary 162
Exercises 163
Chapter 5: Arrays and Iteration 165
Basic Iteration 165
Calling each() Directly 167
Variable Scope 168
Emulating break and continue 170
Iterating a Selection 172
Filtering Selections and Arrays 173
Filtering a Selection 174
Filtering a Selection with a Callback Function 175
Filtering an Array 177
Mapping a Selection or an Array 180
Mapping a Selection 180
Mapping an Array 183
Array Utility Methods 196
Making an Array 197
Finding a Value within an Array 197
xiii
Contents
Merging Two Arrays 198
Removing Duplicate Items 199
Summary 204
Exercises 205
Chapter 6: CSS 207
The css() Method 207
The outerWidth() and outerHeight() Methods 208
Summary 217
Exercises 217
Chapter 7: AJAX 219
Making a Server Request 220
What’s the Difference between GET and POST? 220
Formats Used to Transport Data with an AJAX Request 221
Making a GET Request with jQuery 222
Loading HTML Snippets from the Server 240
Dynamically Loading JavaScript 265
AJAX Events 267
Making an AJAX-Style File Upload 272
Summary 275
Exercises 276
Chapter 8: Effects 277
Showing and Hiding Elements 277
Sliding Elements 279
Fading Elements 280
Custom Animation 281
Summary 283
Exercises 284
Chapter 9: Plugins 285
Writing a Plugin 285
Good Practice for jQuery Plugin Development 295
Summary 296
Exercises 296
xiv
Contents
Part II: jQuery UI 297
Chapter 10: Implementing Drag-and-Drop 299
Making Elements Draggable 300
Making Elements Draggable with Ghosting 308
Dragging between Windows in Safari 311
Delegating Drop Zones for Dragged Elements 314
Summary 326
Exercises 326
Chapter 11: Drag-and-Drop Sorting 327
Making a List Sortable 327
Customizing Sortables 338
Saving the State of Sorted Lists 347
Summary 353
Exercises 354
Chapter 12: Selection by Drawing a Box 355
Introducing the Selectables Plugin 355
Summary 372
Exercises 372
Chapter 13: Accordion UI 373
Building an Accordion UI 373
Setting Auto-Height 376
Changing the Default Pane 377
Toggling the alwaysOpen Option 380
Changing the Accordion Event 380
Filling the Height of the Parent Element 381
Setting the Header Elements 381
Styling Selected Panes 384
Selecting a Content Pane by Location 387
Summary 390
Exercises 391
xv
Contents
Chapter 14: Datepicker 393
Implementing a Datepicker 393
Styling the Datepicker 395
Setting the Range of Allowed Dates 403
Allowing a Date Range to Be Selected 404
Localizing the Datepicker 405
Setting the Date Format 405
Localizing Datepicker Text 406
Changing the Starting Weekday 407
Summary 408
Exercises 408
Chapter 15: Dialogs 409
Implementing a Dialog 409
Examining a Dialog’s Markup 411
Making a Modal Dialog 417
Auto-Opening the Dialog 419
Controlling Dynamic Interaction 420
Animating the Dialog 421
Working with Dialog Events 422
Summary 423
Exercises 424
Chapter 16: Tabs 425
Implementing Tabs 425
Loading Remote Content via AJAX 432
Animating Tab Transitions 436
Summary 437
What Next? 437
Exercises 438
Appendix A: Answers to Exercises 439
Chapter 2 439
Chapter 3 439
Chapter 4 440
Chapter 5 441
xvi
Contents
Chapter 6 441
Chapter 7 442
Chapter 8 442
Chapter 9 443
Chapter 10 443
Chapter 11 444
Chapter 12 444
Chapter 13 444
Chapter 14 445
Chapter 15 445
Chapter 16 445
Appendix B: Selectors Supported by jQuery 447
Appendix C: Selecting and Filtering 451
Appendix D: Events 453
Event Object Normalization 455
Appendix E: Manipulating Attributes and Data Caching 457
Appendix F: Manipulating Content 459
Appendix G: AJAX Methods 461
Appendix H: CSS 465
Appendix I: Utilities 467
Appendix J: Draggables and Droppables 469
Appendix K: Sortables 475
Appendix L: Selectables 479
Notes 480
Appendix M: Effects 481
Speed 481
Callback Function 481
xvii
Contents
Appendix N: Accordion 485
Appendix O: Datepicker 487
Appendix P: Dialog 497
Appendix Q: Tabs 501
Appendix R: Re-Sizables 505
Appendix S: Sliders 509
Index 511
Introduction
The jQuery JavaScript framework is a rising star in the world of web development. JavaScript frame-
works in general have grown to become immensely popular in the past few years in parallel with the
ever-increasing presence of JavaScript-driven, so-called Web 2.0 websites that make heavy use of tech-
nologies like AJAX and JavaScript in general for slick graphical enhancements that would be impossible
or much more cumbersome to incorporate without JavaScript.
jQuery’s mission as a JavaScript library is simple — it strives to make the lives of web developers eas-
ier by patching over certain portions of cross-browser development and by making other tasks com-
monly needed by developers much easier. jQuery has the real, proven ability to reduce many lines of
plain-vanilla JavaScript to just a few lines, and, in many cases, just a single line. jQuery strives to
remove barriers to JavaScript development by removing redundancy wherever possible and normal-
izing cross-browser JavaScript development in key areas where browsers would otherwise differ,
such as Microsoft’s Event API and the W3C Event API, and other, more remedial tasks like getting the
mouse cursor’s position when an event has taken place.
jQuery is a compact, lightweight library that currently works in Microsoft’s Internet Explorer browser
from version 6 on, Firefox from version 1.5 on, Safari from version 2.0.2 on, Opera from version 9 on,
and Google’s new Chrome browser from version 0.2 on. Getting started with jQuery is very easy — all
you have to do is include a single link of markup in your HTML or XHTML documents that includes
the library. Throughout this book, I demonstrate jQuery’s API (Application Programming Interface)
components in detail and show you how all the nuts and bolts of this framework come together to
enable you to rapidly develop client-side applications.
I also cover the jQuery UI library, which makes redundant user-interface (UI) tasks on the client side
ridiculously easy and accessible to everyday web developers who might not have much JavaScript pro-
gramming expertise. Have you ever wanted to create an animated accordion effect like the one found
on Apple’s Mac home page at www.apple.com/mac? With jQuery, not only can you create this effect with
your own look and feel, but also it’s dead simple to boot.
Have you ever wondered how websites make virtual pop-up windows using JavaScript, HTML, and CSS?
The jQuery UI library provides the ability to create these pop-up windows and includes the ability to
animate transitions like fading the window on and off, or having it re-size from very small to full sized.
The jQuery UI library gives you the ability to use animations and transitions using JavaScript, markup,
and CSS that you may have thought previously could only have been done with Adobe’s Flash player.
The jQuery framework itself has enjoyed a great deal of mainstream exposure. It has been used by
Google, Dell, Digg, NBC, CBS, Netflix, The Mozilla Foundation, and the popular WordPress and Drupal
PHP frameworks.
jQuery is fast — superfast — and it has a small footprint. It’s only 15 KB, using the compressed and
gzipped version.
27794flast.indd 19 3/16/09 11:33:36 AM
Introduction
xx
jQuery gives you the ability to provide complex, professional, visually driven user interfaces and effects
with very few lines of code. What may have taken other developers days or even weeks to accomplish
can be done with jQuery in just a few hours.
Who This Book Is For
This book is for anyone interested in doing more with less code! You should have a basic understanding
of JavaScript. I review some basic JavaScript programming concepts, such as the Event API, but I do not
go into great detail about the JavaScript language itself. You’ll want to have at least a basic grasp of the
Document Object Model, or DOM, and basic JavaScript programming syntax. Additionally, you’ll need
to know your way around CSS and HTML, since knowledge of those technologies is also assumed. A
complete beginner might be able to grasp what is taking place in the examples in this book but might
not understand certain terminology and programming concepts that would be presented in a beginner’s
JavaScript guide, so if you are a beginner and insist with pressing forward, I recommend doing so with a
beginning JavaScript book on hand as well. Specifically, I recommend the following Wrox books for
more help with the basics:
Beginning Web Programming with HTML, XHTML, and CSS
❑
❑ , 2nd ed. (2008), by Jon Duckett
Beginning CSS: Cascading Style Sheets for Web Design
❑
❑ , 2nd ed. (2007), also written by yours truly.
Beginning JavaScript
❑
❑ , 3rd ed. (2007), by Paul Wilton and Jeremy McPeak
For further knowledge of JavaScript above and beyond what is covered in this book, I recommend
Professional JavaScript for Web Developers, 2nd ed. (2009), by Nicholas C. Zakas.
What This Book Covers
This book covers the jQuery JavaScript framework and the jQuery UI JavaScript framework and demon-
strates in great detail how to use the jQuery framework to get more results more quickly out of JavaScript
programming. I cover each method exposed by jQuery’s API, which contains methods to make common,
redundant tasks go much more quickly in less code. Some examples are methods that help you to select
elements from a markup document through the DOM and methods that help you to traverse through
those selections and filter them using jQuery’s fine-grained controls. This makes working with the DOM
easier and more effortless. I also cover how jQuery eliminates certain cross-browser, cross-platform devel-
opment headaches like the event model; not only does it eliminate these headaches, but it also makes it
easier to work with events by reducing the amount of code that you need to write to attach events. It even
gives you the ability to simulate events.
Later in the book, I cover how you can leverage the jQuery UI library to make graphically driven UI
widgets. jQuery gives you the ability to break content up among multiple tabs in the same page. You
have the ability to customize the look and feel of the tabs, and even to create a polished look and feel by
providing different effects that come in when you mouse over tabs and click on them. The jQuery UI
library also makes it easy to create accordion sidebars, like the one on Apple’s Mac website. These side-
bars have two or more panels, and when you mouse over an item, one pane transitions to another via a
smooth, seamless animation wherein the preceding pane collapses and the proceeding pane expands.
27794flast.indd 20 3/16/09 11:33:36 AM
Introduction
xxi
The jQuery UI library also gives you the ability to make any element draggable with the mouse; by click-
ing and holding and moving the mouse, you can move elements around on a page. It also makes it really
easy to create drag-and-drop user interfaces. This can be used to make a dropping zone where you take
elements from other parts of the page and drop them in another, as you would in your operating sys-
tem’s file manager when you want to move a folder from one place to another. You can also make lists
that are sortable via drag-and-drop, rearranging elements based on where you drop them. You can also
have a user interface where you drag the mouse cursor to make a selection, as you would in your oper-
ating system’s file manager when you want to select more than one file. Then jQuery UI also exposes the
ability to re-size elements on a page using the mouse. All of those neat things that you can do on your
computer’s desktop, you can also do in a web browser with jQuery UI.
jQuery UI also provides a widget for entering a date into a field using a nice, accessible JavaScript-
driven calendar that pops up when you click on an input field.
You can also make custom pop-up dialogues that are like virtual pop-up windows, except they don’t
open a separate browser window — they come up using markup, CSS, and JavaScript.
Another widget that jQuery UI provides is a graphical slider bar, similar to your media player’s volume
control.
As jQuery has done for JavaScript programming in general, jQuery UI strives to do for redundant
graphical user interface (GUI) tasks. jQuery UI gives you the ability to make professional user-interface
widgets with much less development effort.
If you’re interested in reading news about jQuery, how it’s evolving, and topics related to web develop-
ment, you may be interested in reading the official jQuery blog at blog.jquery.com, or jQuery’s creator,
John Resig’s blog, at www.ejohn.org.
If you are in need of help, you can participate in programming discussion at p2p.wrox.com, which
you can join for free to ask programming questions in moderated forums. There are also program-
ming forums provided by the jQuery community, which you can learn more about at
http://docs.jquery.com/Discussion.
Finally, I maintain a blog and website at www.deadmarshes.com, where you can contact me directly with
your thoughts about the book or read about the web development projects I’m working on.
How This Book Is Structured
This book is divided into two parts: The first half of the book covers the basic API exposed by the jQuery
library, and the second half covers the jQuery UI library.
Part 1: jQuery API
Chapter 1: Introduction to jQuery
❑
❑ — In this first chapter, I discuss a little of where jQuery came
from and why it was needed. Then I walk you through downloading and creating your first
jQuery-enabled JavaScript.
27794flast.indd 21 3/16/09 11:33:36 AM
Introduction
xxii
Chapter 2: Selecting and Filtering
❑
❑ — This chapter introduces jQuery’s selector engine, which
uses selectors like you will have used with CSS to make selections from the DOM. Then I talk
about the various methods that jQuery exposes for working with a selection, to give you fine-
grained control over what elements you’re working with from the DOM. I talk about methods
that let you select, ancestor elements, parent elements, sibling elements, descendent elements,
how to remove elements from a selection, how to add elements to a selection, and how to
reduce a selection to a specific subset of elements.
Chapter 3: Events
❑
❑ — In this chapter, I begin by reviewing the event model as you find it in plain-
vanilla JavaScript. You have the traditional event model, the W3C’s event model, and Microsoft’s
event model. I discuss the differences between these and why jQuery needed an entirely new
Event API to make the situation easier for web developers. Then I present jQuery’s Event API
and how you use it.
Chapter 4: Manipulating Content and Attributes
❑
❑ — In Chapter 4, you learn how to use the
methods that jQuery exposes for working with content, text and HTML, and element attributes.
jQuery provides methods for doing just about everything you’d want to do to an element.
Chapter 5: Arrays and Iteration
❑
❑ — In Chapter 5, I talk about how you can enumerate over a
selection of elements or an array using jQuery. As with everything else, jQuery provides an eas-
ier way that requires fewer lines of code to loop over the contents of an array or a selection of
elements from the DOM.
Chapter 6: CSS
❑
❑ — In this chapter, you learn about the methods that jQuery exposes for working
with CSS properties and declarations. jQuery provides intuitive and versatile methods that let
you manipulate CSS in a variety of ways.
Chapter 7: AJAX
❑
❑ — Chapter 7 elaborates on the methods that jQuery exposes for making AJAX
requests from a server, which allows you to request server content without working directly
with the XMLHttpRequest object and supports handling server responses in a variety of formats.
Chapter 8: Effects
❑
❑ — In Chapter 8, I discuss some helper methods that jQuery exposes for dis-
covering what browser and browser version you’re working with, whether you’re working with
a browser that supports the standard W3C box model for CSS, and a variety of odds and ends
methods for working with objects, arrays, functions, and strings.
Chapter 9: Plugins
❑
❑ — In this chapter, I describe how you can make your own plugins for jQuery.
Part II: jQuery UI
Chapter 10: Implementing Drag-and-Drop
❑
❑ — In Chapter 10, I begin my coverage of the jQuery
UI library by discussing how you make individual elements draggable and how you make a
drag-and-drop interface where you take one element and place it on top of another to create a
complete drag-and-drop sequence.
Chapter 11: Drag-and-Drop Sorting
❑
❑ — In Chapter 11, I discuss how you make lists sortable
using drag-and-drop.
Chapter 12: Selection by Drawing a Box
❑
❑ — In Chapter 12, I cover the portion of the jQuery UI
library that lets you make a selection by drawing a box with your mouse, just like you would do
in your OS’s file management application.
Chapter 13: Accordion UI
❑
❑ — In this chapter, I discuss how to make a really neat, polished-looking
sidebar that has panes that transition like an accordion. When you mouse over an element, one
pane collapses via a slick animation, and another one expands, also via an animation.
27794flast.indd 22 3/16/09 11:33:36 AM
Introduction
xxiii
Chapter 14: Datepicker
❑
❑ — In Chapter 14, I cover how you make a standard form input field
into a Datepicker, using jQuery’s Datepicker widget.
Chapter 15: Dialogs
❑
❑ — In Chapter 15, I talk about how you create virtual pop-up windows,
using the jQuery UI library, that look and act like real pop-up windows but are entirely con-
tained in the same web page that launches them and are built using pure markup, CSS, and
JavaScript.
Chapter 16: Tabs
❑
❑ — In Chapter 16, I discuss the jQuery UI tab component, which allows you to
take a document and split it into several tabs and navigate between those tabs without needing
to load another page.
Appendixes
❑
❑ — Appendix A contains the answers to chapter exercises. Appendix B through
Appendix S contain reference materials for jQuery and jQuery UI.
What You Need to Use This Book
To make use of the examples in this book, you need the following:
Several Internet browsers to test your web pages
❑
❑
Text-editing software or your favorite IDE
❑
❑
Designing content for websites requires being able to reach more than one type of audience. Some of
your audience may be using different operating systems or different browsers other than those you have
installed on your computer. This book focuses on the most popular browsers available at the time of this
writing as supported:
Microsoft Internet Explorer 6 or newer for Windows
❑
❑
Safari for Mac OS X, version 2 or newer
❑
❑
Mozilla Firefox for Mac OS X, Windows, or Linux
❑
❑
Opera for Mac OS X, Windows and Linux, version 9 or newer
❑
❑
Conventions
To help you get the most from the text and keep track of what’s happening, I’ve used a number of con-
ventions throughout the book.
First, be aware that not all the figures referenced in the text actually appear in print. This means, for
example, that the screenshots that actually do appear in a chapter might not be numbered in strict
sequence. For example, if you look only at the screenshots in Chapter 3, the first is Figure 3-1, and the
second is Figure 3-3. There is a reference to Figure 3-2 in the text, but the actual screenshot is not printed.
These “missing” screenshots aren’t really missing, though — they are generated by the code download.
It’s just that for all intents and purposes, they are identical to the screenshots that are printed before or
after them and are therefore not needed in the text.
27794flast.indd 23 3/16/09 11:33:36 AM
Introduction
xxiv
Try It Out
The Try It Out is an exercise you should work through, following the text in the book.
1. It usually consists of a set of steps.
2. Each step has a number.
3. Follow the steps through with your copy of the database.
Boxes like this one hold important, not-to-be forgotten information that is directly
relevant to the surrounding text.
Notes, tips, hints, tricks, and asides to the current discussion are offset and placed in italics like this.
As for styles in the text:
We
❑
❑ highlight with italics new terms and important words when we introduce them.
We show keyboard strokes like this:
❑
❑ Ctrl+A.
We show URLs and code within the text like so:
❑
❑ persistence.properties.
We present code in the following way:
❑
❑
We use a monofont type with no highlighting for most code examples.
Also, Visual Studio’s code editor provides a rich color scheme to indicate various parts of code syntax.
That’s a great tool to help you learn language features in the editor and to help prevent mistakes as you
code. To reinforce Visual Studio’s colors, the code listings in this book are colorized using colors similar
to what you would see on screen in Visual Studio working with the book’s code. In order to optimize
print clarity, some colors have a slightly different hue in print from what you see on screen. But all of
the colors for the code in this book should be close enough to the default Visual Studio colors to give
you an accurate representation of the colors.
Source Code
As you work through the examples in this book, you may choose either to type in all the code manually
or to use the source code files that accompany the book. All of the source code used in this book is avail-
able for download at www.wrox.com. Once at the site, simply locate the book’s title (either by using the
Search box or by using one of the title lists) and click on the Download Code link on the book’s detail
page to obtain all the source code for the book.
Because many books have similar titles, you may find it easiest to search by ISBN; this book’s ISBN is
978-0-470-22779-4.
Once you download the code, just decompress it with your favorite compression tool. Alternatively, you
can go to the main Wrox code download page at www.wrox.com/dynamic/books/download.aspx to see
the code available for this book and all other Wrox books.
27794flast.indd 24 3/16/09 11:33:36 AM
Introduction
xxv
Errata
We make every effort to ensure that there are no errors in the text or in the code. However, no one is
perfect, and mistakes do occur. If you find an error in one of our books, like a spelling mistake or faulty
piece of code, we would be very grateful for your feedback. By sending in errata you may save another
reader hours of frustration, and at the same time, you will be helping us provide even higher quality
information.
To find the errata page for this book, go to www.wrox.com and locate the title using the Search box or one
of the title lists. Then, on the Book Search Results page, click on the Errata link. On this page, you can
view all errata that have been submitted for this book and posted by Wrox editors.
A complete book list including links to errata is also available at
www.wrox.com/misc-pages/booklist.shtml.
If you don’t spot “your” error on the Errata page, click on the Errata Form link and complete the form to
send us the error you have found. We’ll check the information and, if appropriate, post a message to the
book’s Errata page and fix the problem in subsequent editions of the book.
p2p.wrox.com
For author and peer discussion, join the P2P forums at p2p.wrox.com. The forums are a Web-based sys-
tem for you to post messages relating to Wrox books and related technologies and interact with other
readers and technology users. The forums offer a subscription feature to e‑mail you topics of interest of
your choosing when new posts are made to the forums. Wrox authors, editors, other industry experts,
and your fellow readers are present on these forums.
At http://p2p.wrox.com, you will find several different forums that will help you not only as you read
this book, but also as you develop your own applications. To join the forums, just follow these steps:
1. Go to p2p.wrox.com and click on the Register link.
2. Read the terms of use and click Agree.
3. Complete the required information to join as well as any optional information you wish to pro-
vide and click Submit.
4. You will receive an e‑mail with information describing how to verify your account and com-
plete the joining process.
You can read messages in the forums without joining P2P, but in order to post your own messages,
you must join.
Once you join, you can post new messages and respond to messages other users post. You can read
messages at any time on the Web. If you would like to have new messages from a particular forum
e‑mailed to you, click on the “Subscribe to this Forum” icon by the forum name in the forum listing.
For more information about how to use the Wrox P2P, be sure to read the P2P FAQs for answers to ques-
tions about how the forum software works as well as many common questions specific to P2P and Wrox
books. To read the FAQs, click the FAQ link on any P2P page.
27794flast.indd 25 3/16/09 11:33:36 AM
Part I
jQuery API
Chapter 1: Introduction to jQuery
Chapter 2: Selecting and Filtering
Chapter 3: Events
Chapter 4: Manipulating Content and Attributes
Chapter 5: Arrays and Iteration
Chapter 6: CSS
Chapter 7: AJAX
Chapter 8: Effects
Chapter 9: Plugins
1
Introduction to jQuery
JavaScript frameworks have arisen as necessary and useful companions for client-side web devel-
opment. Without JavaScript frameworks, client-side programming becomes a crater-filled mine-
field of cross-browser, cross-platform inconsistencies and idiosyncrasies. JavaScript frameworks
pave over those craters and inconsistencies to create a seamless, enjoyable client-side program-
ming experience.
The most important hole filled by a JavaScript framework is inconsistencies between Internet
Explorer’s and the W3C’s standard Event APIs. jQuery fills in this hole by making a cross-browser
Event API that is very similar to the W3C’s, adding some original helpful extensions of its own.
Another hole filled by most of the popular client-side JavaScript frameworks is the ability to select
and traverse through nodes in the Document Object Model (DOM) using more than the very reme-
dial selection and traversal APIs that are provided by browsers’ default DOM implementations.
jQuery provides a selection mechanism that uses selector syntax like that used in cascading style
sheets. However, not content to support only the standard selectors supported in CSS and even
the new Selectors API implementations supported by WebKit and Internet Explorer 8, jQuery
again extends the standard to support new, innovative, and useful selectors that make sense
when using selectors to select DOM nodes.
In a nutshell, jQuery reduces significantly the amount of JavaScript programming and Q/A (qual-
ity assurance) you have to undertake. It takes what might take several lines of code to write, and
more often than not reduces that to just one or a few lines of code. jQuery makes your JavaScript
more intuitive and easier to understand. jQuery takes JavaScript programming (which at one time
had a higher barrier of entry due to complexity and cross-browser, cross-platform idiosyncrasies)
and makes it easier and more attractive to average web developers.
Throughout this book, I will discuss jQuery’s Application Programming Interface, or API. We’ll
look in depth and up close at each little bit of programming syntax that enables jQuery to do what
it does. With each new bit, I also provide simple, to-the-point examples that demonstrate how that
bit works. I show you how to write JavaScript applications using jQuery, and by the end of this
book, you too will be able to create Web 2.0 applications that function seamlessly across multiple
browsers and platforms.
4
Part I: jQuery API
In this chapter, I begin discussion of jQuery by introducing what you get out of jQuery, who develops
jQuery, how you obtain jQuery, and how you install jQuery and test that it is ready to use.
As I mentioned in the Introduction, I do not assume that you are a JavaScript expert in this book, but I
do assume that you are familiar with basic JavaScript concepts, such as the DOM and attaching events.
I will do my best to keep examples simple and to the point and avoid layering on thick programming
jargon.
What Does jQuery Do for Me?
jQuery makes many tasks easier. Its simplistic, comprehensive API has the ability to completely change
the way you write JavaScript, with the aim of consolidating and eliminating as many common and
redundant tasks as possible. jQuery really shines in the following areas:
jQuery makes iterating and traversing the DOM much easier via its various built-in methods for
❑
❑
doing the same.
jQuery makes selecting items from the DOM easier via its sophisticated, built-in ability to use
❑
❑
selectors, just like you would use in CSS.
jQuery makes it really easy to add your own custom methods via its simple-to-understand
❑
❑
plug-in architecture.
jQuery helps reduce redundancy in navigation and UI functionality, like tabs, CSS and markup-
❑
❑
based pop-up dialogues, animations, and transitions, and lots of other things.
jQuery won’t do your laundry, walk the dog, or broker world peace (yet), but it does bring a lot to the
table in terms of making client-side website development easier.
Is jQuery the only JavaScript framework? — no, certainly not. You can pick from several JavaScript
frameworks: base2, Yahoo UI, Prototype, SproutCore, Dojo, and so on. I picked jQuery for this book
simply because I enjoy its simplicity and lack of verbosity. On the other hand, among the other frame-
works, you’ll find that there is a lot of similarity and each provides its own advantages in terms of uni-
fying Event APIs, providing sophisticated selector and traversal implementations, and providing
simple interfaces for redundant JavaScript-driven UI tasks.
In the past, I’ve been a big fan of base2, simply for its commitment to supporting W3C-sanctioned and
de facto standard APIs seamlessly. But I have decided to focus on jQuery exclusively and exhaustively
for this book because I think its popularity merits comprehensive coverage, which I’m able to present in
a way that is more befitting novice programmers.
In a nutshell, jQuery blurs and even erases lines in some places that existed as barriers for true cross-
browser, cross-platform development. It gives you a standard Event API, a standard Selectors API, use-
ful traversal and enumeration methods, and a very useful UI library that work across the board in
Internet Explorer, Safari, Firefox, and Opera on Windows, Mac, and Linux platforms.
That’s not to say that you won’t ever encounter cross-browser issues with your programs, but jQuery
makes it much less likely and eliminates a hefty chunk of compatibility issues.
5
Chapter 1: Introduction to jQuery
Who Develops jQuery?
I won’t spend a lot of time talking about the history of JavaScript frameworks, why they exist, and so on.
I prefer to get straight to the point. That said, a brief mention of the people involved with developing
jQuery is in order.
jQuery’s lead developer and creator is John Resig, whose website is located at www.ejohn.org. John
resides in Boston, Massachusetts and is a JavaScript Evangelist for the Mozilla Corporation.
There are also several other people who have contributed to jQuery and continue to assist with its
development. You can learn more about these people and what roles they played in jQuery’s develop-
ment at http://docs.jquery.com/About/Contributors.
Obtaining jQuery
jQuery is a free, Open Source JavaScript Framework. The current stable, production release version, as
of this writing, is 1.2.6. I use version 1.2.6 throughout the course of this book. Getting jQuery is easy —
all you have to do is go to www.jquery.com and click on the “Download” link. You’ll see three options
for downloading: a packed and gzipped version, an uncompressed version, and a packed version; these
all refer to the same jQuery script. Download “uncompressed” if you want to be able to look at jQuery’s
source code. Download “packed” if you, for whatever reason, are unable to use gzip compression. The
packed version is the same JavaScript code minus all comments, white space, and line breaks. Otherwise,
for the best possible download performance, the packed and gzipped version is the best.
Installing jQuery
Throughout this book, I will refer to the jQuery script as though it is installed at the following path:
www.example.com/Library/jquery/jquery.js.
Therefore, if I were using the domain example.com, jQuery would have this path from the document
root, /Source Code/jquery/jquery.js. You do not have to install jQuery at this exact path.
The following “Try It Out” assists you with installing jQuery by giving you an alternative dialogue
when the script is properly installed.
Try It Out Installing and Testing jQuery
Example 1-1
To install and test jQuery, follow these steps.
1. Download the jQuery script from www.jquery.com. Alternatively, I have also provided the jQuery
script in this book’s source code download materials available for free from www.wrox.com.
2. Enter the following XHTML document, and save the document as Example 1-1.html. Adjust your
path to jQuery appropriately; the path that I use reflects the path needed for the example to
Other documents randomly have
different content
Beginning JavaScript und CSS development with jQuery 1. ed Edition Richard York
Beginning JavaScript und CSS development with jQuery 1. ed Edition Richard York
Beginning JavaScript und CSS development with jQuery 1. ed Edition Richard York
The Project Gutenberg eBook of The
Unpopular Review, Vol. 2, No. 4, October-
December 1914, including Vol. 2 Index
This ebook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this ebook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.
Title: The Unpopular Review, Vol. 2, No. 4, October-December
1914, including Vol. 2 Index
Author: Various
Editor: Henry Holt
Release date: April 6, 2016 [eBook #51679]
Most recently updated: October 23, 2024
Language: English
Credits: Produced by Tor Martin Kristiansen, Craig Kirkwood,
and
the Online Distributed Proofreading Team at
http://www.pgdp.net (This file was produced from
images
generously made available by The Internet
Archive/American
Libraries.)
*** START OF THE PROJECT GUTENBERG EBOOK THE UNPOPULAR
REVIEW, VOL. 2, NO. 4, OCTOBER-DECEMBER 1914, INCLUDING
VOL. 2 INDEX ***
Beginning JavaScript und CSS development with jQuery 1. ed Edition Richard York
Transcriber’s Notes:
This is The Unpopular Review, Vol. 2, No. 4, October-December, 1914, including the index
for Vol. 2, which consists of Issues No. 3 and 4. Issue No. 3 is posted at Project
Gutenberg as EBook #15876.
The index in the html (web browser) version of this document contains clickable links to
the referenced pages. The targets for the links to pages in Issue No. 3 are in the online
version at Project Gutenberg.
Additional Transcriber’s Notes are at the end.
The Unpopular Review
No. 4 OCTOBER-DECEMBER, 1914 Vol. II
CONTENTS
PAGE
SOME FREE-SPEECH DELUSIONS Fabian Franklin 223
IS SOCIALISM COMING? Preston W. Slosson 236
THE REPUBLIC OF MEGAPHON Grant Showerman 248
THE CURSE OF ADAM AND THE
CURSE OF EVE
F. P. Powers
266
TABU AND TEMPERAMENT Katharine F. Gerould 280
ON HAVING THE BLUES The Editor 301
THE PRINCIPLES AND PRACTICE
OF KICKING
William T. Brewster
318
THE GENTLEMAN-SPORTSMAN Dorothy Canfield
Fisher 334
TRADE UNIONISM IN A
UNIVERSITY
H. C. Bumpus
347
MONARCHY AND DEMOCRACY IN
EDUCATION 356
OUR DEBT TO PSYCHICAL
RESEARCH
H. Addington Bruce
372
THE WAR BY A HISTORIAN F. J. Mather, Jr. 392
THE WAR BY AN ECONOMIST A. S. Johnson 411
THE WAR BY A MAN IN THE
STREET
The Editor
429
EN CASSEROLE: Special to Our Readers, Academic
Courtesy (Mrs. F. G. Allinson), Simplified Spelling 440
INDEX THE UNPOPULAR REVIEW Vol. II 445
Beginning JavaScript und CSS development with jQuery 1. ed Edition Richard York
A
SOME FREE-SPEECH DELUSIONS
singular phenomenon of our time is the invention of a new
species of martyrdom. Resistance to wrong, real or imaginary,
revolt against oppression, the endeavor to overthrow an established
order, has in all ages been attended with hardship and suffering.
When repression or punishment has been cruel or vindictive, and the
victims have cried out against it, in the more humane ages, they
have had in their protest the sympathy and support of right-minded
men, however opposed to the aims of the agitation or revolt in
question. Those who have suffered for their convictions, whether at
the hands of a court or through the bloody judgment of the sword,
have won the name of hero or martyr. The time has been when
those who were known to hold opinions which were regarded as
dangerous to the State, or were obnoxious to the ruling power, fell
under the ban of the Government as criminals. In the last two or
three centuries, among the more liberal and advanced nations,
outright persecution of this kind has been unknown; but between
this merely negative freedom of opinion and that positive freedom
which we understand by the terms “free speech” and “free press”
there is a long distance, the traversing of which has been slow and
irregular. It is possible to maintain that even now, and even in such
countries as the United States or England, this freedom is not
absolute; there are extremely few things, either in government or in
common life, that are absolute. But the remarkable thing about the
outcry for freedom of speech, of which we have lately been hearing
so much, is that this clamor has nothing whatever to do with the
question of the absolute completeness of that freedom. What the
agitators complain of is not that there are some things which they
are not permitted to say or to print; it is not that their publications
are censored or the circulation of them obstructed; it is not that the
doctrines in which they are interested cannot be put before any
assemblage, large or small, which chooses to gather together in an
orderly way to hear them. Their grievance is that at certain times or
places, where the speaking they wish to do would be either an
invasion of ordinary private rights of others, or, in the opinion of the
authorities, an incitement to disorder, the authorities intervene to
prevent these results. The restrictions to which they object are not
limitations as to the nature of the doctrine preached, nor yet
limitations that in any way confine the general spreading of the
doctrine. What they are not allowed to do is—in principle, at least; of
course, there have been blundering applications of it—simply what
nobody else is allowed to do. In a word, what they demand is not
that they shall have the same freedom as the ordinary citizen in
spite of being enemies of the established order, but that they shall
have special privileges and immunities because of being enemies of
the established order.
In keeping with the peculiar character of their grievance is the
character of that factitious martyrdom which they seek to build upon
it. The I. W. W. orator who wishes to speak at the foot of the
Franklin statue in Park Row considers himself—in a mild way, to be
sure—a martyr if, on account of the obstruction of traffic by the
crowd that gathers round him, he is required by the police to hold
his meeting a couple of hundred yards further north; his martyrdom
consisting in the fact that there is very little fun or excitement to be
had out of addressing a crowd which does not obstruct traffic. In the
crowd itself—say the excited and more or less turbulent crowd in
Union Square soon after the Colorado trouble—a man may refuse to
move on at the command of the policeman, and may get a crack on
his head from the policeman’s club; this man certainly has a much
more substantial claim to the title of martyr, and yet his claim is at
least nine parts humbug to one part reality. It may be a pretty
serious thing to the poor fellow himself, or it may not; as a social or
political event it is simply nothing. It would only be something if it
were part of a systematic persecution—an incident of a regular
policy of oppression. Unfortunately there have been places,—say
Lawrence or Paterson—where unwise or wrong-headed local
administrations have been guilty of offences of this kind; but in such
agitations as that of the I. W. W. and their “Free Speech” allies in
New York the grievance has been wholly factitious. There has,
indeed, occurred a tragic climax to these goings-on; the killing of
three of the New York anarchists by the explosion of a bomb which
they were handling, and which there is almost no doubt that they
were engaged in preparing for some work of destruction or
slaughter. But while this is in one sense a less factitious martyrdom
than the others, for it was certainly serious enough, yet in the most
vital element of martyrdom it was obviously lacking altogether.
Nobody invited, still less compelled, these gentlemen to blow
themselves up; and when they did it, they were not engaged in
defending themselves against aggression, nor, presumably, did they
feel that they were in the slightest danger of themselves incurring
the fate they were preparing for others. But all this does not in the
least impede their elevation to the honors of martyrdom; and
incidentally it may be remarked that although those who thus
publicly honor their dead comrades in the cause of revolutionary
anarchy say their say without interference, and go about the city of
New York without molestation, there are not wanting persons who
are ready at any moment to tear their hair over the suppression of
free speech in this community.
But it is in the hunger strike that the new martyrdom is seen full-
fledged, and in its true character. Here we have the fiction of
persecution raised to the second power. The use of it by the free-
speech anarchists is of course only one instance of its exploitation,
but it is the one that specially concerns us here. Whether from its
small beginnings it will develop into a serious nuisance, or perhaps
even take on the dimensions of a grave problem, remains to be
seen. But men of sense should be prepared for the possible spread
of a great deal of foolish and muddled thinking on the subject, and
should from the outset see the thing exactly as it is. In a land of free
discussion, and where the right to vote is exercised without
distinction of class, a certain number of persons are actively
engaged in the agitation of radical or revolutionary changes affecting
the whole social order. No impediment is put in the way of this
propaganda in the shape either of censorship, of hindrance to
publicity, or of personal proscription. They are free to make as many
converts as they can, either by oral persuasion or by the printed
word; and when they have won over a sufficient number, the
government is theirs. Of one instrument, it is true, they are deprived
the use; and it happens that that instrument is the one most to their
liking. They are not allowed to create turbulence or disorder, or to
persecute individuals who have incurred their hostility. In this, they
are treated no otherwise than advocates of the most innocent or
orthodox of causes would be under like circumstances. If there
should arise a Puritan agitation against the theatre, its leaders would
be allowed to denounce the stage to their heart’s content as a
device of the Devil for the corruption and damnation of mankind; but
they would not be permitted to harangue excited crowds that were
ready to mob the actors and actresses or to burn down the theatres.
They would have to content themselves with bringing over to their
way of thinking as many persons as could be won by orderly
methods. It is of this kind of restraint that the anarchists, and other
pretended champions of so-called free speech, complain; it is
against this imaginary grievance that the fraudulent martyrdom of
the hunger strike is a protest.
And it is the fraudulence of the hunger strike, the affront that is
offered to human reason, first in the thing itself, and still more in the
silly cry of “torture” that is raised about it, that every sane man must
most deeply resent. Here is a handful of cheap revolutionists making
themselves more or less of a menace, but certainly very much of a
nuisance, to the constituted authorities. This they do, in general,
without a particle of molestation from the government or of
inconvenience to themselves. Once in a while, when, in these
proceedings, they pass, or are thought to pass, beyond a certain
line, marked out by considerations of public safety or comfort, they
are arrested and subjected to the mild punishment of imprisonment
for a short term, such as is meted out to thousands of petty
offenders. Then they proceed to set themselves up as judges in their
own case; they demand that the law shall surrender to their will.
And when this preposterous demand is met by the application to
them of the most humane methods which professional skill can
devise for securing the accomplishment of their sentence, they rend
the air with shrieks of “torture.” If the sentence itself was unjust, let
them make all possible to-do about it by all means; nobody would
begrudge them that. But they know only too well how little could be
made of any real grievance they could lay claim to; and they count
on a combination of soft-heartedness and soft-headedness in a
considerable part of the public to make a self-inflicted stage-play
torture pass current as the equivalent of the thumb-screw and the
rack. Precisely what the penal authorities had best do if this
foolishness should prove persistent in our country, it may not be
easy to say. The one thing certain is that it cannot be trifled with. It
is an impudent challenge, not only of the law, but of reason and
humanity; and, unless we have quite lost our grip on the realities of
life and government, whatever measures it may be found necessary
to take in order to meet the challenge effectively will receive the
emphatic approval of the American people.
To what extent the fantastic notions of the nature of the right of free
speech that we have been discussing are shared by men of
intelligence and culture, it is difficult to say. They are to be found
distinctly among a certain small and fairly well-defined class of
socialist or semi-socialist clergymen and other humanitarians. In a
wider circle, these notions, if not distinctly embraced, are at all
events given a considerable amount of sympathetic toleration. In
either case, it is not too harsh a judgment to say that the attitude is
due to want of thought or to shallowness of mind. The true doctrine
of free speech is a broad principle of civic conduct, having its
foundations in reason and experience, and its justification in the
highest public expediency; these people appear to think of it as a
simple and absolute dogma, whose sanction transcends all
considerations of expediency, and any violation of which is a sin
against the divine order. Such a view can be entertained only by a
shallow thinker or a one-ideaed fanatic; and it is the former class,
unquestionably, to which nearly all of the “free speech” extremists
are to be assigned. The contrast between their crude and childish
notions and that conception of the doctrine of free speech which is
alone worthy of respect or of serious consideration cannot be better
shown than by quoting the words of one of the greatest champions
of individual liberty the world has ever known. It will hardly be
claimed by even the most effervescent of our sentimental apostles of
free speech that his own convictions on the subject are more
profound, or his courage more uncompromising, than that of John
Stuart Mill. In his noble tractate “On Liberty,” Mill goes as far as
anyone can go—farther no doubt in some respects than many of
these same emotional humanitarians would go—in demanding
complete freedom of public expression, so far as the substance of
the opinions or doctrines in question is concerned. He does not draw
the line at immorality; he does not draw the line at the advocacy of
tyrannicide. But the ardor of his devotion to this principle is that of a
rational thinker, not that of the blind slave of a fetish. That freedom
of speech is made for man, not man for freedom of speech, is to him
so obvious as to require no insisting on. A single brief passage—
introduced at the beginning of his discussion of the question
whether “the same reasons” which prescribe freedom of opinion and
of speech “do not require that men should be free to act upon their
opinions”—will suffice to show this:
No one pretends that actions should be as free as opinions. On
the contrary, even opinions lose their immunity when the
circumstances in which they are expressed are such as to
constitute their expression a positive instigation to some
mischievous act. An opinion that corn-dealers are starvers of the
poor, or that private property is robbery, ought to be
unmolested when simply circulated through the press, but may
justly incur punishment when delivered orally to an excited mob
assembled before the house of a corn-dealer, or when handed
about among the same mob in the form of a placard.
When we note the remark, a little further on, that “the liberty of the
individual must be thus far limited: he must not make himself a
nuisance to other people;” and when we observe that after
maintaining the right of an advocate of the doctrine of tyrannicide
freely to express his opinions, Mill adds that the instigation to it in a
specific case may be a proper subject of punishment, provided “an
overt act has followed, and at least a probable connection can be
established between the act and the instigation,”—we see plainly
enough the difference between the working of a profound and
rational conviction like Mill’s, and that of the shallow-pated
emotionalism which rallies to the support of a Berkman or a Bouck
White.
The confusion of thought which is at the bottom of these vagaries
has been strikingly illustrated in connection with two matters upon
which it may be profitable to dwell at some length. In both
instances, the trouble is in part due to misinformation, or
misconception of the facts; but in both instances the misinformation,
or misconception, is inextricably bound up with the confusion of
thought.
Closely allied to the false notion we have been discussing of what
constitutes suppression of free speech by the authorities is the false
notion, even more prevalent, of what constitutes suppression of the
news by the newspapers. That there are some items of news that do
not get the degree of publicity to which they are entitled may be
quite true; and as regards the treatment by some newspapers of
some whole classes of items, the accusation may be entirely
justified. But that there exists anything like wholesale suppression of
news, among the newspapers of the country generally, and
especially by the Associated Press, is a charge absolutely without
foundation. Regarded as a matter of large and fundamental public
interest—not as a mere matter of ordinary criticism, dealing with
imperfections of execution rather than with wrongfulness of intent—
the question simply lapses for want of body to the accusation. The
things charged as suppressions are so trivial in amount, in
comparison with the vast mass of matter of precisely the same, or
graver, nature carried in the papers, that the idea of the so-called
suppression being anything more than defect in execution—even
though sometimes due to the dishonesty of individuals and not
always to accident or want of adequate equipment—should be
peremptorily dismissed by any man who is accessible to ordinary
argument on the subject.
But in the minds of its chief exponents, the idea that there exists a
wholesale and systematic suppression of news in the interest of
conservatism does not rest upon the omission, or the
misrepresentation, of specific items in the record of what are
generally regarded as the day’s happenings. Their conviction that
the newspapers are guilty of a great and systematic crime against
the truth cannot be overcome by any such comparison as I have
indicated; simply because the scale of values which they habitually
use is fundamentally different from the scale which is current in the
community at large. To their minds, the one absorbing concern of
mankind is to end the iniquities of the existing economic order; and
accordingly, the ordinary news of the day is utterly trivial in
comparison with anything that bears upon the social revolution
which they are sure is impending. Now it would be perfectly possible
to fill many columns of a newspaper every day with matter of this
kind—indeed there would be no difficulty in making up an entire
newspaper of nothing else. The world is very big—even the United
States, even New York city, is very big; and a diligent search for tales
of evil, of hardship, of injustice, of rapacity, of poverty, would be
amply rewarded any day in the year. Moreover, there are strikes,
little and big, in the thousands of industrial and mining centres;
there is every now and then the formation of a Socialist club or the
starting of a little Socialist newspaper; and then there are speeches,
and meetings, and what not. From the point of view of the man who
is convinced that the present order of society is on its last legs, and
that the supreme duty of the journalist is to expose its rottenness,
these are the things with which our papers ought to be filled,
instead of the idle chatter about politics and business. This opinion
they are, of course, fully entitled to entertain; but their charge that
the newspapers suppress the news is essentially based on the notion
that the owners or editors of the papers are themselves of that
opinion, but have not the honesty or the courage to act upon it. And
this is too absurd to call for denial.
The other illustration that I have in mind arises out of the history of
the Chicago Anarchists of 1886. There has gradually spread
throughout the country a notion that the execution of the four
anarchist agitators who were hanged for instigation of the slaughter
of the policemen in Haymarket Square was little better than a
judicial murder. This opinion is expressed in only a little more
extreme form than that which is widely current, by Charles Edward
Russell (late Socialist candidate for Governor of New York) when he
says:
The eight men were convicted, nominally by the jury, in reality
by a misinformed public opinion resolutely bent upon having a
hanging. Anything more like the spirit of a lynching I have never
known under the forms of law.
That a man of Mr. Russell’s type should talk in this way is natural
enough; but it is truly regrettable that an impression approximating
this should be widely entertained among persons of intelligence and
soberness, and having no sympathy at all with the Socialist, not to
speak of the Anarchist, movement. The explanation of this
phenomenon is to be found in part in the absence of knowledge of
the actual facts; but it is to be found in at least equal measure in the
failure to grasp the essential character, and the natural and rational
limits, of the right of free speech.
At a time of great public excitement, arising in connection with a
strike, a bomb was thrown into the midst of a platoon of policemen,
wounding sixty-six of them, seven of whom died of their wounds.
The men who were tried and convicted of this murder had, every
one of them, been engaged in anarchist agitation; they had, every
one of them, been members of a revolutionary society; the two most
conspicuous were active promoters of a propaganda of violence as
editors of revolutionary sheets and as public speakers. But it was not
on these general grounds that the men were convicted. What was
proved at the trial, to the satisfaction of the twelve jurymen and of
the judge, was that these men were guilty of direct incitement to the
precise kind of act that was actually committed—the killing of
policemen as the defenders of the rights of property and the
maintainers of law and order. Now the trouble with the tender-
minded people who so easily accept the view that the executed
Anarchists were martyrs of free speech and victims of something like
lynch law is that they never ask themselves the question whether, in
point of fact, these men were really instigators of the crime in the
sense required by the law to make them murderers, or were not.
The trial lasted nearly six weeks; it was perfectly orderly; and this
question—the question of whether these men were legally guilty of
murder—was put before the jury in the sharpest possible way by the
judge. It was that question which they decided; it was upon that
question that Judge Gary, who presided over the trial, declared, in a
remarkable and convincing article written seven years later and
published in the Century Magazine, that the verdict was absolutely
sound, and involved no stretching of the law. Finally, it should be
remembered above all—and yet it is constantly forgotten—that the
Supreme Court of Illinois, a year after the trial, sustained the
proceedings in a unanimous judgment; its opinion, covering 150
pages of the Illinois reports, being an exhaustive review not only of
the law, but also of the facts of the case. To speak of a trial so
conducted, and stamped with such approval, as being a proceeding
in the nature of a lynching, is not only preposterous, but impudent.
In the foregoing discussion, and in the illustrations that have been
adduced, what I have chiefly endeavored to bring out is the
unreasonableness, and the practical absurdity, of the unthinking
view which passes current with many for the noble and rational
doctrine of freedom of speech and of the press. It may be well to
add, in conclusion, a few words on a broader aspect of the matter.
Just as religion may be made repulsive and odious by narrowness
and bigotry; just as scientific or philosophic thought may be
perverted by a spirit of intolerant dogmatism; so a high and inspiring
doctrine of human conduct and polity may degenerate into an object
of merited contempt when divorced from those considerations upon
which its justification rests, and erected into a mere formula, to be
followed with superstitious servility. That the absurdities which have
been put forward in the name of the doctrine of free speech will
actually have the effect of thus degrading and discrediting that
doctrine, is not likely; but it is not likely only because common sense
and sound feeling may be counted on to keep the folly from
spreading. Yet it is the duty of men of light and leading to make
clear their own position on the subject whenever it comes
conspicuously to the front. They can in no better way serve the
permanent interests of the cause of true freedom of speech than by
showing, beyond the possibility of mistake, their contempt for the
cheap counterfeit of it. In all the clamor that has been set up by the
Bouck Whites and the Berkmans and the Upton Sinclairs, has any
one pointed to a single doctrine that has been suppressed, a single
teacher that has been silenced, a single truth, or alleged truth, that
the authorities have endeavored to stifle? Time was when the
champions of free speech have had to fight in order that men who
had a message to deliver should have a chance to deliver it; what
these make-believe apostles and martyrs have to fight for now is a
chance to be suppressed. Nobody asks what it was that Bouck White
or Becky Edelson wanted to say; what they ask is how he came to
be dragged out of a church, or how she came to be arrested for
being disorderly. And nobody asks the former question for two
reasons—first, that the newspapers freely print what these people
have to say; and secondly, that what they have to say is utterly
familiar and commonplace. Suppression is not, with them, an
obstacle to the spread of their teachings; on the contrary, it is their
chief stock-in-trade, their sole claim to the attention of the public.
What has elevated the doctrine of freedom of opinion and of speech
to the lofty place which it holds in the estimation of mankind is the
conviction, slowly acquired through ages of physical and spiritual
struggle, that by that freedom can best be served the cause of truth,
and hence the advancement of humanity. But with this neither the
vulgar stage business of the New York Anarchists of today, nor the
crazy appeals to the pistol and the bomb of the Chicago Anarchists
of 1886, has anything whatever to do. To identify either with the
great historic doctrine of free speech is to debase the intellectual
and moral coinage of the race.
Beginning JavaScript und CSS development with jQuery 1. ed Edition Richard York
E
IS SOCIALISM COMING?
And when the pedants bade us mark
What cold mechanic happenings
Must come; our souls said in the dark,
“Belike; but there are likelier things.”
G. K. Chesterton.
very historian today owes much to Karl Marx for his development
of the “Economic Interpretation of History.” Whatever that theory
may fail to explain, it certainly succeeds in explaining the nature and
growth of the Socialist movement. When the great attempt at real
political and economic democracy made by the French people in
their great Revolution had failed and left behind it as a legacy the
memory of the Terror and the wars of Napoleon, every nation in
Europe felt the reaction. Russia, Austria, Spain and non-industrial
Europe generally reacted towards simple absolutism, noble against
peasant. But in the countries within the boundary marked out by the
industrial revolution, the wealth created by the new machines placed
the balance of economic power in the hands of the commercial
classes, and so forced the old landed aristocracy to admit them to
political power as well. In the meanwhile the first shock of large
scale production had widened the gap between the industrial
workers and the employing class. Independent artisans were ruined
or forced into factories, and in the wake of the new industry there
trailed a network of industrial oligarchies which spread until they
covered the civilized world. The already enfranchised classes refused
to use their power to moderate the harshness of the competitive
struggle, honestly believing that any interference with “economic
law” could work nothing but ruin and hardship in the end.
In view of the facts as they existed in the days of the Communist
Manifesto it was practically inevitable that an economist in sympathy
with the economically powerless and politically disfranchised masses
should interpret history as did the Marxians. In an age of coal, iron
and steam (that potent trinity), of large scale production, of
capitalistic agriculture, of economic tyranny, of sharpening class
divergence and increasing poverty, it seemed that there was no way
to realize democracy but to wait until industry had been
concentrated into the hands of a few rich men, till the middle class
and the free peasantry had been reduced to the proletarian ranks,
and till the ever increasing misery of the workers taught them to
combine and seize the means of production and distribution by a
single revolutionary stroke. Private property could have appeared
only as a tool for robbing the workers of the “surplus value” of their
labor, religion as an ingenious means of sidetracking revolutionary
activities, and patriotism as an excuse for standing armies and
protective tariffs. This was a tenable explanation of the world—in
1848!
But the world has moved since the day of the Manifesto. Now
manhood suffrage is the rule and not the exception. The worst forms
of factory serfdom have been ended by legislative and economic
changes. The various reform parties of Europe and America and
even the Conservatives compete with each other for the
workingman’s vote by programs of social amelioration which steadily
grow more ambitious every year. Socialism itself has altered in a
changing world. The “Revisionist” or common-sense wing of the
party has abandoned both the “surplus value” metaphysics, and the
prophecy, so happily falsified, of “increasing misery” and “cumulative
panics,” and has moderated the class war dogma far enough to
permit working hand in hand with the once hated bourgeoisie for
immediate reforms. Other Socialists still repeat the old catchwords,
but modify them by a process of “interpretation” analogous to that
which makes Liberal Christians content to repeat the historic creeds.
Of course some revolutionists have looked upon this readjustment
with misgivings, and, as a result, we have sporadic and badly led
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!
ebookultra.com

More Related Content

PDF
Beginning JavaScript und CSS development with jQuery 1. ed Edition Richard York
PDF
Beginning JavaScript und CSS development with jQuery 1. ed Edition Richard York
PDF
Beginning CSS Cascading Style Sheets for Web Design Wrox Beginning Guides 2nd...
PDF
Beginning CSS Cascading Style Sheets for Web Design Wrox Beginning Guides 2nd...
PDF
Beginning Css Cascading Style Sheets For Web Design Wrox Beginning Guides 2nd...
PDF
Mastering Javaserver Faces Bill Dudney Jonathan Lehr Bill Willis
PDF
Professional Microsoft Sql Server Analysis Services 2008 With Mdx Sivakumar H...
PDF
Beginning XML 4th ed Edition David Hunter
Beginning JavaScript und CSS development with jQuery 1. ed Edition Richard York
Beginning JavaScript und CSS development with jQuery 1. ed Edition Richard York
Beginning CSS Cascading Style Sheets for Web Design Wrox Beginning Guides 2nd...
Beginning CSS Cascading Style Sheets for Web Design Wrox Beginning Guides 2nd...
Beginning Css Cascading Style Sheets For Web Design Wrox Beginning Guides 2nd...
Mastering Javaserver Faces Bill Dudney Jonathan Lehr Bill Willis
Professional Microsoft Sql Server Analysis Services 2008 With Mdx Sivakumar H...
Beginning XML 4th ed Edition David Hunter

Similar to Beginning JavaScript und CSS development with jQuery 1. ed Edition Richard York (20)

PDF
Download full ebook of Cloud-native Computing Pethuru Raj instant download pdf
PDF
Data Mining the Web Uncovering Patterns in Web Content Structure and Usage 1s...
PDF
Data Mining the Web Uncovering Patterns in Web Content Structure and Usage 1s...
PDF
Beginning XML 4th ed Edition David Hunter
PDF
Data Mining The Web Uncovering Patterns In Web Content Structure And Usage 1s...
PDF
Wroxs Sql Server 2005 Express Edition Starter Kit Rajesh George
PDF
Microsoft project silk
PDF
From Traditional Fault Tolerance To Blockchain Wenbing Zhao
PDF
Javascript Essentials For Dummies Paul Mcfedries
PDF
snowpro (1).pdf
PDF
Special Edition Using Javascript Mcfedries
PDF
Making Use of JSP 1st Edition Madhushree Ganguli
PDF
Making use of Python 1st Edition Rashi Gupta
PDF
Special Edition Using Javascript Mcfedries
PDF
J2ee Open Source Toolkit Building An Enterprise Platform With Open Source Too...
PDF
Core Servlets and Javaserver Pages Advanced Technologies 2nd Edition Marty Hall
PDF
Professional Vsto 2005 Visual Studio 2005 Tools For Office Alvin Bruney
PDF
Core JavaServer TM Faces 2nd Edition David Geary
PDF
Web 20 Security Defending Ajax Ria And Soa Shreeraj Shah
PDF
Making use of Python 1st Edition Rashi Gupta
Download full ebook of Cloud-native Computing Pethuru Raj instant download pdf
Data Mining the Web Uncovering Patterns in Web Content Structure and Usage 1s...
Data Mining the Web Uncovering Patterns in Web Content Structure and Usage 1s...
Beginning XML 4th ed Edition David Hunter
Data Mining The Web Uncovering Patterns In Web Content Structure And Usage 1s...
Wroxs Sql Server 2005 Express Edition Starter Kit Rajesh George
Microsoft project silk
From Traditional Fault Tolerance To Blockchain Wenbing Zhao
Javascript Essentials For Dummies Paul Mcfedries
snowpro (1).pdf
Special Edition Using Javascript Mcfedries
Making Use of JSP 1st Edition Madhushree Ganguli
Making use of Python 1st Edition Rashi Gupta
Special Edition Using Javascript Mcfedries
J2ee Open Source Toolkit Building An Enterprise Platform With Open Source Too...
Core Servlets and Javaserver Pages Advanced Technologies 2nd Edition Marty Hall
Professional Vsto 2005 Visual Studio 2005 Tools For Office Alvin Bruney
Core JavaServer TM Faces 2nd Edition David Geary
Web 20 Security Defending Ajax Ria And Soa Shreeraj Shah
Making use of Python 1st Edition Rashi Gupta
Ad

Recently uploaded (20)

PDF
Complications of Minimal Access Surgery at WLH
PDF
Insiders guide to clinical Medicine.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
master seminar digital applications in india
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Sports Quiz easy sports quiz sports quiz
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Anesthesia in Laparoscopic Surgery in India
Complications of Minimal Access Surgery at WLH
Insiders guide to clinical Medicine.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Final Presentation General Medicine 03-08-2024.pptx
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
Renaissance Architecture: A Journey from Faith to Humanism
GDM (1) (1).pptx small presentation for students
Pharmacology of Heart Failure /Pharmacotherapy of CHF
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
master seminar digital applications in india
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
VCE English Exam - Section C Student Revision Booklet
O7-L3 Supply Chain Operations - ICLT Program
Abdominal Access Techniques with Prof. Dr. R K Mishra
Sports Quiz easy sports quiz sports quiz
PPH.pptx obstetrics and gynecology in nursing
Anesthesia in Laparoscopic Surgery in India
Ad

Beginning JavaScript und CSS development with jQuery 1. ed Edition Richard York

  • 1. Visit https://ebookultra.com to download the full version and explore more ebooks or textbooks Beginning JavaScript und CSS development with jQuery 1. ed Edition Richard York _____ Click the link below to download _____ https://ebookultra.com/download/beginning-javascript-und- css-development-with-jquery-1-ed-edition-richard-york/ Explore and download more ebooks or textbooks at ebookultra.com
  • 2. Here are some recommended products that we believe you will be interested in. You can click the link to download. Beginning CSS Cascading Style Sheets for Web Design Wrox Beginning Guides 2nd Edition Richard York https://ebookultra.com/download/beginning-css-cascading-style-sheets- for-web-design-wrox-beginning-guides-2nd-edition-richard-york/ Joomla 1 5 JavaScript jQuery 1st Edition Jose Argudo Blanco https://ebookultra.com/download/joomla-1-5-javascript-jquery-1st- edition-jose-argudo-blanco/ Beginning JavaScript 3rd ed Edition Paul Wilton https://ebookultra.com/download/beginning-javascript-3rd-ed-edition- paul-wilton/ Professional XMPP Programming with JavaScript and jQuery 1st Edition Jack Moffitt https://ebookultra.com/download/professional-xmpp-programming-with- javascript-and-jquery-1st-edition-jack-moffitt/
  • 3. Beginning Windows Store Application Development HTML and JavaScript Edition Scott Isaacs https://ebookultra.com/download/beginning-windows-store-application- development-html-and-javascript-edition-scott-isaacs/ Html 5 Black Book Covers Css 3 Javascript Xml Xhtml Ajax Php And Jquery 2Ed 2nd Edition Dt Editorial Services https://ebookultra.com/download/html-5-black-book-covers- css-3-javascript-xml-xhtml-ajax-php-and-jquery-2ed-2nd-edition-dt- editorial-services/ jQuery and JavaScript Phrasebook 1st Edition Brad Dayley https://ebookultra.com/download/jquery-and-javascript-phrasebook-1st- edition-brad-dayley/ Drupal 6 JavaScript and jQuery 1st Edition Matt Butcher https://ebookultra.com/download/drupal-6-javascript-and-jquery-1st- edition-matt-butcher/ Beginning JavaScript 5th Edition Jeremy Mcpeak https://ebookultra.com/download/beginning-javascript-5th-edition- jeremy-mcpeak/
  • 5. Beginning JavaScript und CSS development with jQuery 1. ed Edition Richard York Digital Instant Download Author(s): Richard York ISBN(s): 9780470227794, 0470227796 Edition: 1. ed File Details: PDF, 7.18 MB Year: 2009 Language: english
  • 6. Beginning JavaScript®and CSS Development with jQuery Richard York 27794ffirs.indd 5 3/16/09 3:14:20 PM
  • 7. Beginning JavaScript® and CSS Development with jQuery Published by Wiley Publishing, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright © 2009 by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN: 978-0-470-22779-4 Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 Library of Congress Cataloging-in-Publication Data York, Richard. Beginning JavaScript and CSS development with jQuery / Richard York. p. cm. Includes index. ISBN 978-0-470-22779-4 (paper/website) 1. JavaScript (Computer program language) 2. Web sites--Design. 3. Cascading style sheets. I. Title. QA76.73.J38Y67 2009 006.7’6--dc22 2009005636 No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions. Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or pro- motional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the services of a competent professional person should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Web site is referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses the information the organization or Web site may provide or recommendations it may make. Further, readers should be aware that Internet Web sites listed in this work may have changed or disappeared between when this work was written and when it is read. For general information on our other products and services please contact our Customer Care Department within the United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002. Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Programmer to Programmer, and related trade dress are trade- marks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission. JavaScript is a registered trademark of Sun Microsystems, Inc. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. 27794ffirs.indd 6 3/16/09 3:14:20 PM
  • 8. Contents Introduction xix Part I: jQuery API 1 Chapter 1: Introduction to jQuery 3 What Does jQuery Do for Me? 4 Who Develops jQuery? 5 Obtaining jQuery 5 Installing jQuery 5 Programming Conventions 8 XHTML and CSS Conventions 9 JavaScript Conventions 16 Summary 25 Chapter 2: Selecting and Filtering 27 The Origin of the Selectors API 28 Using the Selectors API 29 Filtering a Selection 37 Searching within a Selection with find() 38 Finding an Element’s Siblings with siblings() 39 Selecting Specific Siblings 42 Searching Ancestors Using the parents() and parent() Methods 46 Selecting Children Elements 48 Selecting Elements via What You Don’t Want 50 Selecting a Snippet of the Results 51 Adding More Elements to a Selection 53 Selecting One Specific Element from a Result Set 55 Summary 66 Exercises 66 Chapter 3: Events 69 Assigning an Event with the Traditional Event Model 69 Assigning Events with the W3C Event Model 72 The this Object 73 The event Object 75
  • 9. xii Contents The Microsoft JScript Event Model 77 Creating a Universal Event API 78 Binding Events with jQuery’s bind() Method 80 Binding Events with jQuery’s Event Methods 82 Triggering Events 83 Summary 93 Exercises 93 Chapter 4: Manipulating Content and Attributes 95 Setting and Accessing Attributes 95 Manipulating Class Names 105 Manipulating HTML and Text Content 109 Getting, Setting, and Removing Content 110 Appending and Prepending Content 115 Inserting Beside Content 123 Inserting Beside Content via a Selection 125 Wrapping Content 129 Replacing Elements 146 Removing Content 150 Cloning Content 154 Summary 162 Exercises 163 Chapter 5: Arrays and Iteration 165 Basic Iteration 165 Calling each() Directly 167 Variable Scope 168 Emulating break and continue 170 Iterating a Selection 172 Filtering Selections and Arrays 173 Filtering a Selection 174 Filtering a Selection with a Callback Function 175 Filtering an Array 177 Mapping a Selection or an Array 180 Mapping a Selection 180 Mapping an Array 183 Array Utility Methods 196 Making an Array 197 Finding a Value within an Array 197
  • 10. xiii Contents Merging Two Arrays 198 Removing Duplicate Items 199 Summary 204 Exercises 205 Chapter 6: CSS 207 The css() Method 207 The outerWidth() and outerHeight() Methods 208 Summary 217 Exercises 217 Chapter 7: AJAX 219 Making a Server Request 220 What’s the Difference between GET and POST? 220 Formats Used to Transport Data with an AJAX Request 221 Making a GET Request with jQuery 222 Loading HTML Snippets from the Server 240 Dynamically Loading JavaScript 265 AJAX Events 267 Making an AJAX-Style File Upload 272 Summary 275 Exercises 276 Chapter 8: Effects 277 Showing and Hiding Elements 277 Sliding Elements 279 Fading Elements 280 Custom Animation 281 Summary 283 Exercises 284 Chapter 9: Plugins 285 Writing a Plugin 285 Good Practice for jQuery Plugin Development 295 Summary 296 Exercises 296
  • 11. xiv Contents Part II: jQuery UI 297 Chapter 10: Implementing Drag-and-Drop 299 Making Elements Draggable 300 Making Elements Draggable with Ghosting 308 Dragging between Windows in Safari 311 Delegating Drop Zones for Dragged Elements 314 Summary 326 Exercises 326 Chapter 11: Drag-and-Drop Sorting 327 Making a List Sortable 327 Customizing Sortables 338 Saving the State of Sorted Lists 347 Summary 353 Exercises 354 Chapter 12: Selection by Drawing a Box 355 Introducing the Selectables Plugin 355 Summary 372 Exercises 372 Chapter 13: Accordion UI 373 Building an Accordion UI 373 Setting Auto-Height 376 Changing the Default Pane 377 Toggling the alwaysOpen Option 380 Changing the Accordion Event 380 Filling the Height of the Parent Element 381 Setting the Header Elements 381 Styling Selected Panes 384 Selecting a Content Pane by Location 387 Summary 390 Exercises 391
  • 12. xv Contents Chapter 14: Datepicker 393 Implementing a Datepicker 393 Styling the Datepicker 395 Setting the Range of Allowed Dates 403 Allowing a Date Range to Be Selected 404 Localizing the Datepicker 405 Setting the Date Format 405 Localizing Datepicker Text 406 Changing the Starting Weekday 407 Summary 408 Exercises 408 Chapter 15: Dialogs 409 Implementing a Dialog 409 Examining a Dialog’s Markup 411 Making a Modal Dialog 417 Auto-Opening the Dialog 419 Controlling Dynamic Interaction 420 Animating the Dialog 421 Working with Dialog Events 422 Summary 423 Exercises 424 Chapter 16: Tabs 425 Implementing Tabs 425 Loading Remote Content via AJAX 432 Animating Tab Transitions 436 Summary 437 What Next? 437 Exercises 438 Appendix A: Answers to Exercises 439 Chapter 2 439 Chapter 3 439 Chapter 4 440 Chapter 5 441
  • 13. xvi Contents Chapter 6 441 Chapter 7 442 Chapter 8 442 Chapter 9 443 Chapter 10 443 Chapter 11 444 Chapter 12 444 Chapter 13 444 Chapter 14 445 Chapter 15 445 Chapter 16 445 Appendix B: Selectors Supported by jQuery 447 Appendix C: Selecting and Filtering 451 Appendix D: Events 453 Event Object Normalization 455 Appendix E: Manipulating Attributes and Data Caching 457 Appendix F: Manipulating Content 459 Appendix G: AJAX Methods 461 Appendix H: CSS 465 Appendix I: Utilities 467 Appendix J: Draggables and Droppables 469 Appendix K: Sortables 475 Appendix L: Selectables 479 Notes 480 Appendix M: Effects 481 Speed 481 Callback Function 481
  • 14. xvii Contents Appendix N: Accordion 485 Appendix O: Datepicker 487 Appendix P: Dialog 497 Appendix Q: Tabs 501 Appendix R: Re-Sizables 505 Appendix S: Sliders 509 Index 511
  • 15. Introduction The jQuery JavaScript framework is a rising star in the world of web development. JavaScript frame- works in general have grown to become immensely popular in the past few years in parallel with the ever-increasing presence of JavaScript-driven, so-called Web 2.0 websites that make heavy use of tech- nologies like AJAX and JavaScript in general for slick graphical enhancements that would be impossible or much more cumbersome to incorporate without JavaScript. jQuery’s mission as a JavaScript library is simple — it strives to make the lives of web developers eas- ier by patching over certain portions of cross-browser development and by making other tasks com- monly needed by developers much easier. jQuery has the real, proven ability to reduce many lines of plain-vanilla JavaScript to just a few lines, and, in many cases, just a single line. jQuery strives to remove barriers to JavaScript development by removing redundancy wherever possible and normal- izing cross-browser JavaScript development in key areas where browsers would otherwise differ, such as Microsoft’s Event API and the W3C Event API, and other, more remedial tasks like getting the mouse cursor’s position when an event has taken place. jQuery is a compact, lightweight library that currently works in Microsoft’s Internet Explorer browser from version 6 on, Firefox from version 1.5 on, Safari from version 2.0.2 on, Opera from version 9 on, and Google’s new Chrome browser from version 0.2 on. Getting started with jQuery is very easy — all you have to do is include a single link of markup in your HTML or XHTML documents that includes the library. Throughout this book, I demonstrate jQuery’s API (Application Programming Interface) components in detail and show you how all the nuts and bolts of this framework come together to enable you to rapidly develop client-side applications. I also cover the jQuery UI library, which makes redundant user-interface (UI) tasks on the client side ridiculously easy and accessible to everyday web developers who might not have much JavaScript pro- gramming expertise. Have you ever wanted to create an animated accordion effect like the one found on Apple’s Mac home page at www.apple.com/mac? With jQuery, not only can you create this effect with your own look and feel, but also it’s dead simple to boot. Have you ever wondered how websites make virtual pop-up windows using JavaScript, HTML, and CSS? The jQuery UI library provides the ability to create these pop-up windows and includes the ability to animate transitions like fading the window on and off, or having it re-size from very small to full sized. The jQuery UI library gives you the ability to use animations and transitions using JavaScript, markup, and CSS that you may have thought previously could only have been done with Adobe’s Flash player. The jQuery framework itself has enjoyed a great deal of mainstream exposure. It has been used by Google, Dell, Digg, NBC, CBS, Netflix, The Mozilla Foundation, and the popular WordPress and Drupal PHP frameworks. jQuery is fast — superfast — and it has a small footprint. It’s only 15 KB, using the compressed and gzipped version. 27794flast.indd 19 3/16/09 11:33:36 AM
  • 16. Introduction xx jQuery gives you the ability to provide complex, professional, visually driven user interfaces and effects with very few lines of code. What may have taken other developers days or even weeks to accomplish can be done with jQuery in just a few hours. Who This Book Is For This book is for anyone interested in doing more with less code! You should have a basic understanding of JavaScript. I review some basic JavaScript programming concepts, such as the Event API, but I do not go into great detail about the JavaScript language itself. You’ll want to have at least a basic grasp of the Document Object Model, or DOM, and basic JavaScript programming syntax. Additionally, you’ll need to know your way around CSS and HTML, since knowledge of those technologies is also assumed. A complete beginner might be able to grasp what is taking place in the examples in this book but might not understand certain terminology and programming concepts that would be presented in a beginner’s JavaScript guide, so if you are a beginner and insist with pressing forward, I recommend doing so with a beginning JavaScript book on hand as well. Specifically, I recommend the following Wrox books for more help with the basics: Beginning Web Programming with HTML, XHTML, and CSS ❑ ❑ , 2nd ed. (2008), by Jon Duckett Beginning CSS: Cascading Style Sheets for Web Design ❑ ❑ , 2nd ed. (2007), also written by yours truly. Beginning JavaScript ❑ ❑ , 3rd ed. (2007), by Paul Wilton and Jeremy McPeak For further knowledge of JavaScript above and beyond what is covered in this book, I recommend Professional JavaScript for Web Developers, 2nd ed. (2009), by Nicholas C. Zakas. What This Book Covers This book covers the jQuery JavaScript framework and the jQuery UI JavaScript framework and demon- strates in great detail how to use the jQuery framework to get more results more quickly out of JavaScript programming. I cover each method exposed by jQuery’s API, which contains methods to make common, redundant tasks go much more quickly in less code. Some examples are methods that help you to select elements from a markup document through the DOM and methods that help you to traverse through those selections and filter them using jQuery’s fine-grained controls. This makes working with the DOM easier and more effortless. I also cover how jQuery eliminates certain cross-browser, cross-platform devel- opment headaches like the event model; not only does it eliminate these headaches, but it also makes it easier to work with events by reducing the amount of code that you need to write to attach events. It even gives you the ability to simulate events. Later in the book, I cover how you can leverage the jQuery UI library to make graphically driven UI widgets. jQuery gives you the ability to break content up among multiple tabs in the same page. You have the ability to customize the look and feel of the tabs, and even to create a polished look and feel by providing different effects that come in when you mouse over tabs and click on them. The jQuery UI library also makes it easy to create accordion sidebars, like the one on Apple’s Mac website. These side- bars have two or more panels, and when you mouse over an item, one pane transitions to another via a smooth, seamless animation wherein the preceding pane collapses and the proceeding pane expands. 27794flast.indd 20 3/16/09 11:33:36 AM
  • 17. Introduction xxi The jQuery UI library also gives you the ability to make any element draggable with the mouse; by click- ing and holding and moving the mouse, you can move elements around on a page. It also makes it really easy to create drag-and-drop user interfaces. This can be used to make a dropping zone where you take elements from other parts of the page and drop them in another, as you would in your operating sys- tem’s file manager when you want to move a folder from one place to another. You can also make lists that are sortable via drag-and-drop, rearranging elements based on where you drop them. You can also have a user interface where you drag the mouse cursor to make a selection, as you would in your oper- ating system’s file manager when you want to select more than one file. Then jQuery UI also exposes the ability to re-size elements on a page using the mouse. All of those neat things that you can do on your computer’s desktop, you can also do in a web browser with jQuery UI. jQuery UI also provides a widget for entering a date into a field using a nice, accessible JavaScript- driven calendar that pops up when you click on an input field. You can also make custom pop-up dialogues that are like virtual pop-up windows, except they don’t open a separate browser window — they come up using markup, CSS, and JavaScript. Another widget that jQuery UI provides is a graphical slider bar, similar to your media player’s volume control. As jQuery has done for JavaScript programming in general, jQuery UI strives to do for redundant graphical user interface (GUI) tasks. jQuery UI gives you the ability to make professional user-interface widgets with much less development effort. If you’re interested in reading news about jQuery, how it’s evolving, and topics related to web develop- ment, you may be interested in reading the official jQuery blog at blog.jquery.com, or jQuery’s creator, John Resig’s blog, at www.ejohn.org. If you are in need of help, you can participate in programming discussion at p2p.wrox.com, which you can join for free to ask programming questions in moderated forums. There are also program- ming forums provided by the jQuery community, which you can learn more about at http://docs.jquery.com/Discussion. Finally, I maintain a blog and website at www.deadmarshes.com, where you can contact me directly with your thoughts about the book or read about the web development projects I’m working on. How This Book Is Structured This book is divided into two parts: The first half of the book covers the basic API exposed by the jQuery library, and the second half covers the jQuery UI library. Part 1: jQuery API Chapter 1: Introduction to jQuery ❑ ❑ — In this first chapter, I discuss a little of where jQuery came from and why it was needed. Then I walk you through downloading and creating your first jQuery-enabled JavaScript. 27794flast.indd 21 3/16/09 11:33:36 AM
  • 18. Introduction xxii Chapter 2: Selecting and Filtering ❑ ❑ — This chapter introduces jQuery’s selector engine, which uses selectors like you will have used with CSS to make selections from the DOM. Then I talk about the various methods that jQuery exposes for working with a selection, to give you fine- grained control over what elements you’re working with from the DOM. I talk about methods that let you select, ancestor elements, parent elements, sibling elements, descendent elements, how to remove elements from a selection, how to add elements to a selection, and how to reduce a selection to a specific subset of elements. Chapter 3: Events ❑ ❑ — In this chapter, I begin by reviewing the event model as you find it in plain- vanilla JavaScript. You have the traditional event model, the W3C’s event model, and Microsoft’s event model. I discuss the differences between these and why jQuery needed an entirely new Event API to make the situation easier for web developers. Then I present jQuery’s Event API and how you use it. Chapter 4: Manipulating Content and Attributes ❑ ❑ — In Chapter 4, you learn how to use the methods that jQuery exposes for working with content, text and HTML, and element attributes. jQuery provides methods for doing just about everything you’d want to do to an element. Chapter 5: Arrays and Iteration ❑ ❑ — In Chapter 5, I talk about how you can enumerate over a selection of elements or an array using jQuery. As with everything else, jQuery provides an eas- ier way that requires fewer lines of code to loop over the contents of an array or a selection of elements from the DOM. Chapter 6: CSS ❑ ❑ — In this chapter, you learn about the methods that jQuery exposes for working with CSS properties and declarations. jQuery provides intuitive and versatile methods that let you manipulate CSS in a variety of ways. Chapter 7: AJAX ❑ ❑ — Chapter 7 elaborates on the methods that jQuery exposes for making AJAX requests from a server, which allows you to request server content without working directly with the XMLHttpRequest object and supports handling server responses in a variety of formats. Chapter 8: Effects ❑ ❑ — In Chapter 8, I discuss some helper methods that jQuery exposes for dis- covering what browser and browser version you’re working with, whether you’re working with a browser that supports the standard W3C box model for CSS, and a variety of odds and ends methods for working with objects, arrays, functions, and strings. Chapter 9: Plugins ❑ ❑ — In this chapter, I describe how you can make your own plugins for jQuery. Part II: jQuery UI Chapter 10: Implementing Drag-and-Drop ❑ ❑ — In Chapter 10, I begin my coverage of the jQuery UI library by discussing how you make individual elements draggable and how you make a drag-and-drop interface where you take one element and place it on top of another to create a complete drag-and-drop sequence. Chapter 11: Drag-and-Drop Sorting ❑ ❑ — In Chapter 11, I discuss how you make lists sortable using drag-and-drop. Chapter 12: Selection by Drawing a Box ❑ ❑ — In Chapter 12, I cover the portion of the jQuery UI library that lets you make a selection by drawing a box with your mouse, just like you would do in your OS’s file management application. Chapter 13: Accordion UI ❑ ❑ — In this chapter, I discuss how to make a really neat, polished-looking sidebar that has panes that transition like an accordion. When you mouse over an element, one pane collapses via a slick animation, and another one expands, also via an animation. 27794flast.indd 22 3/16/09 11:33:36 AM
  • 19. Introduction xxiii Chapter 14: Datepicker ❑ ❑ — In Chapter 14, I cover how you make a standard form input field into a Datepicker, using jQuery’s Datepicker widget. Chapter 15: Dialogs ❑ ❑ — In Chapter 15, I talk about how you create virtual pop-up windows, using the jQuery UI library, that look and act like real pop-up windows but are entirely con- tained in the same web page that launches them and are built using pure markup, CSS, and JavaScript. Chapter 16: Tabs ❑ ❑ — In Chapter 16, I discuss the jQuery UI tab component, which allows you to take a document and split it into several tabs and navigate between those tabs without needing to load another page. Appendixes ❑ ❑ — Appendix A contains the answers to chapter exercises. Appendix B through Appendix S contain reference materials for jQuery and jQuery UI. What You Need to Use This Book To make use of the examples in this book, you need the following: Several Internet browsers to test your web pages ❑ ❑ Text-editing software or your favorite IDE ❑ ❑ Designing content for websites requires being able to reach more than one type of audience. Some of your audience may be using different operating systems or different browsers other than those you have installed on your computer. This book focuses on the most popular browsers available at the time of this writing as supported: Microsoft Internet Explorer 6 or newer for Windows ❑ ❑ Safari for Mac OS X, version 2 or newer ❑ ❑ Mozilla Firefox for Mac OS X, Windows, or Linux ❑ ❑ Opera for Mac OS X, Windows and Linux, version 9 or newer ❑ ❑ Conventions To help you get the most from the text and keep track of what’s happening, I’ve used a number of con- ventions throughout the book. First, be aware that not all the figures referenced in the text actually appear in print. This means, for example, that the screenshots that actually do appear in a chapter might not be numbered in strict sequence. For example, if you look only at the screenshots in Chapter 3, the first is Figure 3-1, and the second is Figure 3-3. There is a reference to Figure 3-2 in the text, but the actual screenshot is not printed. These “missing” screenshots aren’t really missing, though — they are generated by the code download. It’s just that for all intents and purposes, they are identical to the screenshots that are printed before or after them and are therefore not needed in the text. 27794flast.indd 23 3/16/09 11:33:36 AM
  • 20. Introduction xxiv Try It Out The Try It Out is an exercise you should work through, following the text in the book. 1. It usually consists of a set of steps. 2. Each step has a number. 3. Follow the steps through with your copy of the database. Boxes like this one hold important, not-to-be forgotten information that is directly relevant to the surrounding text. Notes, tips, hints, tricks, and asides to the current discussion are offset and placed in italics like this. As for styles in the text: We ❑ ❑ highlight with italics new terms and important words when we introduce them. We show keyboard strokes like this: ❑ ❑ Ctrl+A. We show URLs and code within the text like so: ❑ ❑ persistence.properties. We present code in the following way: ❑ ❑ We use a monofont type with no highlighting for most code examples. Also, Visual Studio’s code editor provides a rich color scheme to indicate various parts of code syntax. That’s a great tool to help you learn language features in the editor and to help prevent mistakes as you code. To reinforce Visual Studio’s colors, the code listings in this book are colorized using colors similar to what you would see on screen in Visual Studio working with the book’s code. In order to optimize print clarity, some colors have a slightly different hue in print from what you see on screen. But all of the colors for the code in this book should be close enough to the default Visual Studio colors to give you an accurate representation of the colors. Source Code As you work through the examples in this book, you may choose either to type in all the code manually or to use the source code files that accompany the book. All of the source code used in this book is avail- able for download at www.wrox.com. Once at the site, simply locate the book’s title (either by using the Search box or by using one of the title lists) and click on the Download Code link on the book’s detail page to obtain all the source code for the book. Because many books have similar titles, you may find it easiest to search by ISBN; this book’s ISBN is 978-0-470-22779-4. Once you download the code, just decompress it with your favorite compression tool. Alternatively, you can go to the main Wrox code download page at www.wrox.com/dynamic/books/download.aspx to see the code available for this book and all other Wrox books. 27794flast.indd 24 3/16/09 11:33:36 AM
  • 21. Introduction xxv Errata We make every effort to ensure that there are no errors in the text or in the code. However, no one is perfect, and mistakes do occur. If you find an error in one of our books, like a spelling mistake or faulty piece of code, we would be very grateful for your feedback. By sending in errata you may save another reader hours of frustration, and at the same time, you will be helping us provide even higher quality information. To find the errata page for this book, go to www.wrox.com and locate the title using the Search box or one of the title lists. Then, on the Book Search Results page, click on the Errata link. On this page, you can view all errata that have been submitted for this book and posted by Wrox editors. A complete book list including links to errata is also available at www.wrox.com/misc-pages/booklist.shtml. If you don’t spot “your” error on the Errata page, click on the Errata Form link and complete the form to send us the error you have found. We’ll check the information and, if appropriate, post a message to the book’s Errata page and fix the problem in subsequent editions of the book. p2p.wrox.com For author and peer discussion, join the P2P forums at p2p.wrox.com. The forums are a Web-based sys- tem for you to post messages relating to Wrox books and related technologies and interact with other readers and technology users. The forums offer a subscription feature to e‑mail you topics of interest of your choosing when new posts are made to the forums. Wrox authors, editors, other industry experts, and your fellow readers are present on these forums. At http://p2p.wrox.com, you will find several different forums that will help you not only as you read this book, but also as you develop your own applications. To join the forums, just follow these steps: 1. Go to p2p.wrox.com and click on the Register link. 2. Read the terms of use and click Agree. 3. Complete the required information to join as well as any optional information you wish to pro- vide and click Submit. 4. You will receive an e‑mail with information describing how to verify your account and com- plete the joining process. You can read messages in the forums without joining P2P, but in order to post your own messages, you must join. Once you join, you can post new messages and respond to messages other users post. You can read messages at any time on the Web. If you would like to have new messages from a particular forum e‑mailed to you, click on the “Subscribe to this Forum” icon by the forum name in the forum listing. For more information about how to use the Wrox P2P, be sure to read the P2P FAQs for answers to ques- tions about how the forum software works as well as many common questions specific to P2P and Wrox books. To read the FAQs, click the FAQ link on any P2P page. 27794flast.indd 25 3/16/09 11:33:36 AM
  • 22. Part I jQuery API Chapter 1: Introduction to jQuery Chapter 2: Selecting and Filtering Chapter 3: Events Chapter 4: Manipulating Content and Attributes Chapter 5: Arrays and Iteration Chapter 6: CSS Chapter 7: AJAX Chapter 8: Effects Chapter 9: Plugins
  • 23. 1 Introduction to jQuery JavaScript frameworks have arisen as necessary and useful companions for client-side web devel- opment. Without JavaScript frameworks, client-side programming becomes a crater-filled mine- field of cross-browser, cross-platform inconsistencies and idiosyncrasies. JavaScript frameworks pave over those craters and inconsistencies to create a seamless, enjoyable client-side program- ming experience. The most important hole filled by a JavaScript framework is inconsistencies between Internet Explorer’s and the W3C’s standard Event APIs. jQuery fills in this hole by making a cross-browser Event API that is very similar to the W3C’s, adding some original helpful extensions of its own. Another hole filled by most of the popular client-side JavaScript frameworks is the ability to select and traverse through nodes in the Document Object Model (DOM) using more than the very reme- dial selection and traversal APIs that are provided by browsers’ default DOM implementations. jQuery provides a selection mechanism that uses selector syntax like that used in cascading style sheets. However, not content to support only the standard selectors supported in CSS and even the new Selectors API implementations supported by WebKit and Internet Explorer 8, jQuery again extends the standard to support new, innovative, and useful selectors that make sense when using selectors to select DOM nodes. In a nutshell, jQuery reduces significantly the amount of JavaScript programming and Q/A (qual- ity assurance) you have to undertake. It takes what might take several lines of code to write, and more often than not reduces that to just one or a few lines of code. jQuery makes your JavaScript more intuitive and easier to understand. jQuery takes JavaScript programming (which at one time had a higher barrier of entry due to complexity and cross-browser, cross-platform idiosyncrasies) and makes it easier and more attractive to average web developers. Throughout this book, I will discuss jQuery’s Application Programming Interface, or API. We’ll look in depth and up close at each little bit of programming syntax that enables jQuery to do what it does. With each new bit, I also provide simple, to-the-point examples that demonstrate how that bit works. I show you how to write JavaScript applications using jQuery, and by the end of this book, you too will be able to create Web 2.0 applications that function seamlessly across multiple browsers and platforms.
  • 24. 4 Part I: jQuery API In this chapter, I begin discussion of jQuery by introducing what you get out of jQuery, who develops jQuery, how you obtain jQuery, and how you install jQuery and test that it is ready to use. As I mentioned in the Introduction, I do not assume that you are a JavaScript expert in this book, but I do assume that you are familiar with basic JavaScript concepts, such as the DOM and attaching events. I will do my best to keep examples simple and to the point and avoid layering on thick programming jargon. What Does jQuery Do for Me? jQuery makes many tasks easier. Its simplistic, comprehensive API has the ability to completely change the way you write JavaScript, with the aim of consolidating and eliminating as many common and redundant tasks as possible. jQuery really shines in the following areas: jQuery makes iterating and traversing the DOM much easier via its various built-in methods for ❑ ❑ doing the same. jQuery makes selecting items from the DOM easier via its sophisticated, built-in ability to use ❑ ❑ selectors, just like you would use in CSS. jQuery makes it really easy to add your own custom methods via its simple-to-understand ❑ ❑ plug-in architecture. jQuery helps reduce redundancy in navigation and UI functionality, like tabs, CSS and markup- ❑ ❑ based pop-up dialogues, animations, and transitions, and lots of other things. jQuery won’t do your laundry, walk the dog, or broker world peace (yet), but it does bring a lot to the table in terms of making client-side website development easier. Is jQuery the only JavaScript framework? — no, certainly not. You can pick from several JavaScript frameworks: base2, Yahoo UI, Prototype, SproutCore, Dojo, and so on. I picked jQuery for this book simply because I enjoy its simplicity and lack of verbosity. On the other hand, among the other frame- works, you’ll find that there is a lot of similarity and each provides its own advantages in terms of uni- fying Event APIs, providing sophisticated selector and traversal implementations, and providing simple interfaces for redundant JavaScript-driven UI tasks. In the past, I’ve been a big fan of base2, simply for its commitment to supporting W3C-sanctioned and de facto standard APIs seamlessly. But I have decided to focus on jQuery exclusively and exhaustively for this book because I think its popularity merits comprehensive coverage, which I’m able to present in a way that is more befitting novice programmers. In a nutshell, jQuery blurs and even erases lines in some places that existed as barriers for true cross- browser, cross-platform development. It gives you a standard Event API, a standard Selectors API, use- ful traversal and enumeration methods, and a very useful UI library that work across the board in Internet Explorer, Safari, Firefox, and Opera on Windows, Mac, and Linux platforms. That’s not to say that you won’t ever encounter cross-browser issues with your programs, but jQuery makes it much less likely and eliminates a hefty chunk of compatibility issues.
  • 25. 5 Chapter 1: Introduction to jQuery Who Develops jQuery? I won’t spend a lot of time talking about the history of JavaScript frameworks, why they exist, and so on. I prefer to get straight to the point. That said, a brief mention of the people involved with developing jQuery is in order. jQuery’s lead developer and creator is John Resig, whose website is located at www.ejohn.org. John resides in Boston, Massachusetts and is a JavaScript Evangelist for the Mozilla Corporation. There are also several other people who have contributed to jQuery and continue to assist with its development. You can learn more about these people and what roles they played in jQuery’s develop- ment at http://docs.jquery.com/About/Contributors. Obtaining jQuery jQuery is a free, Open Source JavaScript Framework. The current stable, production release version, as of this writing, is 1.2.6. I use version 1.2.6 throughout the course of this book. Getting jQuery is easy — all you have to do is go to www.jquery.com and click on the “Download” link. You’ll see three options for downloading: a packed and gzipped version, an uncompressed version, and a packed version; these all refer to the same jQuery script. Download “uncompressed” if you want to be able to look at jQuery’s source code. Download “packed” if you, for whatever reason, are unable to use gzip compression. The packed version is the same JavaScript code minus all comments, white space, and line breaks. Otherwise, for the best possible download performance, the packed and gzipped version is the best. Installing jQuery Throughout this book, I will refer to the jQuery script as though it is installed at the following path: www.example.com/Library/jquery/jquery.js. Therefore, if I were using the domain example.com, jQuery would have this path from the document root, /Source Code/jquery/jquery.js. You do not have to install jQuery at this exact path. The following “Try It Out” assists you with installing jQuery by giving you an alternative dialogue when the script is properly installed. Try It Out Installing and Testing jQuery Example 1-1 To install and test jQuery, follow these steps. 1. Download the jQuery script from www.jquery.com. Alternatively, I have also provided the jQuery script in this book’s source code download materials available for free from www.wrox.com. 2. Enter the following XHTML document, and save the document as Example 1-1.html. Adjust your path to jQuery appropriately; the path that I use reflects the path needed for the example to
  • 26. Other documents randomly have different content
  • 30. The Project Gutenberg eBook of The Unpopular Review, Vol. 2, No. 4, October- December 1914, including Vol. 2 Index
  • 31. This ebook is for the use of anyone anywhere in the United States and most other parts of the world at no cost and with almost no restrictions whatsoever. You may copy it, give it away or re-use it under the terms of the Project Gutenberg License included with this ebook or online at www.gutenberg.org. If you are not located in the United States, you will have to check the laws of the country where you are located before using this eBook. Title: The Unpopular Review, Vol. 2, No. 4, October-December 1914, including Vol. 2 Index Author: Various Editor: Henry Holt Release date: April 6, 2016 [eBook #51679] Most recently updated: October 23, 2024 Language: English Credits: Produced by Tor Martin Kristiansen, Craig Kirkwood, and the Online Distributed Proofreading Team at http://www.pgdp.net (This file was produced from images generously made available by The Internet Archive/American Libraries.) *** START OF THE PROJECT GUTENBERG EBOOK THE UNPOPULAR REVIEW, VOL. 2, NO. 4, OCTOBER-DECEMBER 1914, INCLUDING VOL. 2 INDEX ***
  • 33. Transcriber’s Notes: This is The Unpopular Review, Vol. 2, No. 4, October-December, 1914, including the index for Vol. 2, which consists of Issues No. 3 and 4. Issue No. 3 is posted at Project Gutenberg as EBook #15876. The index in the html (web browser) version of this document contains clickable links to the referenced pages. The targets for the links to pages in Issue No. 3 are in the online version at Project Gutenberg. Additional Transcriber’s Notes are at the end.
  • 34. The Unpopular Review No. 4 OCTOBER-DECEMBER, 1914 Vol. II
  • 35. CONTENTS PAGE SOME FREE-SPEECH DELUSIONS Fabian Franklin 223 IS SOCIALISM COMING? Preston W. Slosson 236 THE REPUBLIC OF MEGAPHON Grant Showerman 248 THE CURSE OF ADAM AND THE CURSE OF EVE F. P. Powers 266 TABU AND TEMPERAMENT Katharine F. Gerould 280 ON HAVING THE BLUES The Editor 301 THE PRINCIPLES AND PRACTICE OF KICKING William T. Brewster 318 THE GENTLEMAN-SPORTSMAN Dorothy Canfield Fisher 334 TRADE UNIONISM IN A UNIVERSITY H. C. Bumpus 347 MONARCHY AND DEMOCRACY IN EDUCATION 356 OUR DEBT TO PSYCHICAL RESEARCH H. Addington Bruce 372 THE WAR BY A HISTORIAN F. J. Mather, Jr. 392 THE WAR BY AN ECONOMIST A. S. Johnson 411 THE WAR BY A MAN IN THE STREET The Editor 429
  • 36. EN CASSEROLE: Special to Our Readers, Academic Courtesy (Mrs. F. G. Allinson), Simplified Spelling 440 INDEX THE UNPOPULAR REVIEW Vol. II 445
  • 38. A SOME FREE-SPEECH DELUSIONS singular phenomenon of our time is the invention of a new species of martyrdom. Resistance to wrong, real or imaginary, revolt against oppression, the endeavor to overthrow an established order, has in all ages been attended with hardship and suffering. When repression or punishment has been cruel or vindictive, and the victims have cried out against it, in the more humane ages, they have had in their protest the sympathy and support of right-minded men, however opposed to the aims of the agitation or revolt in question. Those who have suffered for their convictions, whether at the hands of a court or through the bloody judgment of the sword, have won the name of hero or martyr. The time has been when those who were known to hold opinions which were regarded as dangerous to the State, or were obnoxious to the ruling power, fell under the ban of the Government as criminals. In the last two or three centuries, among the more liberal and advanced nations, outright persecution of this kind has been unknown; but between this merely negative freedom of opinion and that positive freedom which we understand by the terms “free speech” and “free press” there is a long distance, the traversing of which has been slow and irregular. It is possible to maintain that even now, and even in such countries as the United States or England, this freedom is not absolute; there are extremely few things, either in government or in common life, that are absolute. But the remarkable thing about the outcry for freedom of speech, of which we have lately been hearing so much, is that this clamor has nothing whatever to do with the question of the absolute completeness of that freedom. What the agitators complain of is not that there are some things which they are not permitted to say or to print; it is not that their publications are censored or the circulation of them obstructed; it is not that the doctrines in which they are interested cannot be put before any
  • 39. assemblage, large or small, which chooses to gather together in an orderly way to hear them. Their grievance is that at certain times or places, where the speaking they wish to do would be either an invasion of ordinary private rights of others, or, in the opinion of the authorities, an incitement to disorder, the authorities intervene to prevent these results. The restrictions to which they object are not limitations as to the nature of the doctrine preached, nor yet limitations that in any way confine the general spreading of the doctrine. What they are not allowed to do is—in principle, at least; of course, there have been blundering applications of it—simply what nobody else is allowed to do. In a word, what they demand is not that they shall have the same freedom as the ordinary citizen in spite of being enemies of the established order, but that they shall have special privileges and immunities because of being enemies of the established order. In keeping with the peculiar character of their grievance is the character of that factitious martyrdom which they seek to build upon it. The I. W. W. orator who wishes to speak at the foot of the Franklin statue in Park Row considers himself—in a mild way, to be sure—a martyr if, on account of the obstruction of traffic by the crowd that gathers round him, he is required by the police to hold his meeting a couple of hundred yards further north; his martyrdom consisting in the fact that there is very little fun or excitement to be had out of addressing a crowd which does not obstruct traffic. In the crowd itself—say the excited and more or less turbulent crowd in Union Square soon after the Colorado trouble—a man may refuse to move on at the command of the policeman, and may get a crack on his head from the policeman’s club; this man certainly has a much more substantial claim to the title of martyr, and yet his claim is at least nine parts humbug to one part reality. It may be a pretty serious thing to the poor fellow himself, or it may not; as a social or political event it is simply nothing. It would only be something if it were part of a systematic persecution—an incident of a regular policy of oppression. Unfortunately there have been places,—say Lawrence or Paterson—where unwise or wrong-headed local
  • 40. administrations have been guilty of offences of this kind; but in such agitations as that of the I. W. W. and their “Free Speech” allies in New York the grievance has been wholly factitious. There has, indeed, occurred a tragic climax to these goings-on; the killing of three of the New York anarchists by the explosion of a bomb which they were handling, and which there is almost no doubt that they were engaged in preparing for some work of destruction or slaughter. But while this is in one sense a less factitious martyrdom than the others, for it was certainly serious enough, yet in the most vital element of martyrdom it was obviously lacking altogether. Nobody invited, still less compelled, these gentlemen to blow themselves up; and when they did it, they were not engaged in defending themselves against aggression, nor, presumably, did they feel that they were in the slightest danger of themselves incurring the fate they were preparing for others. But all this does not in the least impede their elevation to the honors of martyrdom; and incidentally it may be remarked that although those who thus publicly honor their dead comrades in the cause of revolutionary anarchy say their say without interference, and go about the city of New York without molestation, there are not wanting persons who are ready at any moment to tear their hair over the suppression of free speech in this community. But it is in the hunger strike that the new martyrdom is seen full- fledged, and in its true character. Here we have the fiction of persecution raised to the second power. The use of it by the free- speech anarchists is of course only one instance of its exploitation, but it is the one that specially concerns us here. Whether from its small beginnings it will develop into a serious nuisance, or perhaps even take on the dimensions of a grave problem, remains to be seen. But men of sense should be prepared for the possible spread of a great deal of foolish and muddled thinking on the subject, and should from the outset see the thing exactly as it is. In a land of free discussion, and where the right to vote is exercised without distinction of class, a certain number of persons are actively engaged in the agitation of radical or revolutionary changes affecting
  • 41. the whole social order. No impediment is put in the way of this propaganda in the shape either of censorship, of hindrance to publicity, or of personal proscription. They are free to make as many converts as they can, either by oral persuasion or by the printed word; and when they have won over a sufficient number, the government is theirs. Of one instrument, it is true, they are deprived the use; and it happens that that instrument is the one most to their liking. They are not allowed to create turbulence or disorder, or to persecute individuals who have incurred their hostility. In this, they are treated no otherwise than advocates of the most innocent or orthodox of causes would be under like circumstances. If there should arise a Puritan agitation against the theatre, its leaders would be allowed to denounce the stage to their heart’s content as a device of the Devil for the corruption and damnation of mankind; but they would not be permitted to harangue excited crowds that were ready to mob the actors and actresses or to burn down the theatres. They would have to content themselves with bringing over to their way of thinking as many persons as could be won by orderly methods. It is of this kind of restraint that the anarchists, and other pretended champions of so-called free speech, complain; it is against this imaginary grievance that the fraudulent martyrdom of the hunger strike is a protest. And it is the fraudulence of the hunger strike, the affront that is offered to human reason, first in the thing itself, and still more in the silly cry of “torture” that is raised about it, that every sane man must most deeply resent. Here is a handful of cheap revolutionists making themselves more or less of a menace, but certainly very much of a nuisance, to the constituted authorities. This they do, in general, without a particle of molestation from the government or of inconvenience to themselves. Once in a while, when, in these proceedings, they pass, or are thought to pass, beyond a certain line, marked out by considerations of public safety or comfort, they are arrested and subjected to the mild punishment of imprisonment for a short term, such as is meted out to thousands of petty offenders. Then they proceed to set themselves up as judges in their
  • 42. own case; they demand that the law shall surrender to their will. And when this preposterous demand is met by the application to them of the most humane methods which professional skill can devise for securing the accomplishment of their sentence, they rend the air with shrieks of “torture.” If the sentence itself was unjust, let them make all possible to-do about it by all means; nobody would begrudge them that. But they know only too well how little could be made of any real grievance they could lay claim to; and they count on a combination of soft-heartedness and soft-headedness in a considerable part of the public to make a self-inflicted stage-play torture pass current as the equivalent of the thumb-screw and the rack. Precisely what the penal authorities had best do if this foolishness should prove persistent in our country, it may not be easy to say. The one thing certain is that it cannot be trifled with. It is an impudent challenge, not only of the law, but of reason and humanity; and, unless we have quite lost our grip on the realities of life and government, whatever measures it may be found necessary to take in order to meet the challenge effectively will receive the emphatic approval of the American people. To what extent the fantastic notions of the nature of the right of free speech that we have been discussing are shared by men of intelligence and culture, it is difficult to say. They are to be found distinctly among a certain small and fairly well-defined class of socialist or semi-socialist clergymen and other humanitarians. In a wider circle, these notions, if not distinctly embraced, are at all events given a considerable amount of sympathetic toleration. In either case, it is not too harsh a judgment to say that the attitude is due to want of thought or to shallowness of mind. The true doctrine of free speech is a broad principle of civic conduct, having its foundations in reason and experience, and its justification in the highest public expediency; these people appear to think of it as a simple and absolute dogma, whose sanction transcends all
  • 43. considerations of expediency, and any violation of which is a sin against the divine order. Such a view can be entertained only by a shallow thinker or a one-ideaed fanatic; and it is the former class, unquestionably, to which nearly all of the “free speech” extremists are to be assigned. The contrast between their crude and childish notions and that conception of the doctrine of free speech which is alone worthy of respect or of serious consideration cannot be better shown than by quoting the words of one of the greatest champions of individual liberty the world has ever known. It will hardly be claimed by even the most effervescent of our sentimental apostles of free speech that his own convictions on the subject are more profound, or his courage more uncompromising, than that of John Stuart Mill. In his noble tractate “On Liberty,” Mill goes as far as anyone can go—farther no doubt in some respects than many of these same emotional humanitarians would go—in demanding complete freedom of public expression, so far as the substance of the opinions or doctrines in question is concerned. He does not draw the line at immorality; he does not draw the line at the advocacy of tyrannicide. But the ardor of his devotion to this principle is that of a rational thinker, not that of the blind slave of a fetish. That freedom of speech is made for man, not man for freedom of speech, is to him so obvious as to require no insisting on. A single brief passage— introduced at the beginning of his discussion of the question whether “the same reasons” which prescribe freedom of opinion and of speech “do not require that men should be free to act upon their opinions”—will suffice to show this: No one pretends that actions should be as free as opinions. On the contrary, even opinions lose their immunity when the circumstances in which they are expressed are such as to constitute their expression a positive instigation to some mischievous act. An opinion that corn-dealers are starvers of the poor, or that private property is robbery, ought to be unmolested when simply circulated through the press, but may justly incur punishment when delivered orally to an excited mob
  • 44. assembled before the house of a corn-dealer, or when handed about among the same mob in the form of a placard. When we note the remark, a little further on, that “the liberty of the individual must be thus far limited: he must not make himself a nuisance to other people;” and when we observe that after maintaining the right of an advocate of the doctrine of tyrannicide freely to express his opinions, Mill adds that the instigation to it in a specific case may be a proper subject of punishment, provided “an overt act has followed, and at least a probable connection can be established between the act and the instigation,”—we see plainly enough the difference between the working of a profound and rational conviction like Mill’s, and that of the shallow-pated emotionalism which rallies to the support of a Berkman or a Bouck White. The confusion of thought which is at the bottom of these vagaries has been strikingly illustrated in connection with two matters upon which it may be profitable to dwell at some length. In both instances, the trouble is in part due to misinformation, or misconception of the facts; but in both instances the misinformation, or misconception, is inextricably bound up with the confusion of thought. Closely allied to the false notion we have been discussing of what constitutes suppression of free speech by the authorities is the false notion, even more prevalent, of what constitutes suppression of the news by the newspapers. That there are some items of news that do not get the degree of publicity to which they are entitled may be quite true; and as regards the treatment by some newspapers of some whole classes of items, the accusation may be entirely justified. But that there exists anything like wholesale suppression of news, among the newspapers of the country generally, and especially by the Associated Press, is a charge absolutely without
  • 45. foundation. Regarded as a matter of large and fundamental public interest—not as a mere matter of ordinary criticism, dealing with imperfections of execution rather than with wrongfulness of intent— the question simply lapses for want of body to the accusation. The things charged as suppressions are so trivial in amount, in comparison with the vast mass of matter of precisely the same, or graver, nature carried in the papers, that the idea of the so-called suppression being anything more than defect in execution—even though sometimes due to the dishonesty of individuals and not always to accident or want of adequate equipment—should be peremptorily dismissed by any man who is accessible to ordinary argument on the subject. But in the minds of its chief exponents, the idea that there exists a wholesale and systematic suppression of news in the interest of conservatism does not rest upon the omission, or the misrepresentation, of specific items in the record of what are generally regarded as the day’s happenings. Their conviction that the newspapers are guilty of a great and systematic crime against the truth cannot be overcome by any such comparison as I have indicated; simply because the scale of values which they habitually use is fundamentally different from the scale which is current in the community at large. To their minds, the one absorbing concern of mankind is to end the iniquities of the existing economic order; and accordingly, the ordinary news of the day is utterly trivial in comparison with anything that bears upon the social revolution which they are sure is impending. Now it would be perfectly possible to fill many columns of a newspaper every day with matter of this kind—indeed there would be no difficulty in making up an entire newspaper of nothing else. The world is very big—even the United States, even New York city, is very big; and a diligent search for tales of evil, of hardship, of injustice, of rapacity, of poverty, would be amply rewarded any day in the year. Moreover, there are strikes, little and big, in the thousands of industrial and mining centres; there is every now and then the formation of a Socialist club or the starting of a little Socialist newspaper; and then there are speeches,
  • 46. and meetings, and what not. From the point of view of the man who is convinced that the present order of society is on its last legs, and that the supreme duty of the journalist is to expose its rottenness, these are the things with which our papers ought to be filled, instead of the idle chatter about politics and business. This opinion they are, of course, fully entitled to entertain; but their charge that the newspapers suppress the news is essentially based on the notion that the owners or editors of the papers are themselves of that opinion, but have not the honesty or the courage to act upon it. And this is too absurd to call for denial. The other illustration that I have in mind arises out of the history of the Chicago Anarchists of 1886. There has gradually spread throughout the country a notion that the execution of the four anarchist agitators who were hanged for instigation of the slaughter of the policemen in Haymarket Square was little better than a judicial murder. This opinion is expressed in only a little more extreme form than that which is widely current, by Charles Edward Russell (late Socialist candidate for Governor of New York) when he says: The eight men were convicted, nominally by the jury, in reality by a misinformed public opinion resolutely bent upon having a hanging. Anything more like the spirit of a lynching I have never known under the forms of law. That a man of Mr. Russell’s type should talk in this way is natural enough; but it is truly regrettable that an impression approximating this should be widely entertained among persons of intelligence and soberness, and having no sympathy at all with the Socialist, not to speak of the Anarchist, movement. The explanation of this phenomenon is to be found in part in the absence of knowledge of the actual facts; but it is to be found in at least equal measure in the
  • 47. failure to grasp the essential character, and the natural and rational limits, of the right of free speech. At a time of great public excitement, arising in connection with a strike, a bomb was thrown into the midst of a platoon of policemen, wounding sixty-six of them, seven of whom died of their wounds. The men who were tried and convicted of this murder had, every one of them, been engaged in anarchist agitation; they had, every one of them, been members of a revolutionary society; the two most conspicuous were active promoters of a propaganda of violence as editors of revolutionary sheets and as public speakers. But it was not on these general grounds that the men were convicted. What was proved at the trial, to the satisfaction of the twelve jurymen and of the judge, was that these men were guilty of direct incitement to the precise kind of act that was actually committed—the killing of policemen as the defenders of the rights of property and the maintainers of law and order. Now the trouble with the tender- minded people who so easily accept the view that the executed Anarchists were martyrs of free speech and victims of something like lynch law is that they never ask themselves the question whether, in point of fact, these men were really instigators of the crime in the sense required by the law to make them murderers, or were not. The trial lasted nearly six weeks; it was perfectly orderly; and this question—the question of whether these men were legally guilty of murder—was put before the jury in the sharpest possible way by the judge. It was that question which they decided; it was upon that question that Judge Gary, who presided over the trial, declared, in a remarkable and convincing article written seven years later and published in the Century Magazine, that the verdict was absolutely sound, and involved no stretching of the law. Finally, it should be remembered above all—and yet it is constantly forgotten—that the Supreme Court of Illinois, a year after the trial, sustained the proceedings in a unanimous judgment; its opinion, covering 150 pages of the Illinois reports, being an exhaustive review not only of the law, but also of the facts of the case. To speak of a trial so
  • 48. conducted, and stamped with such approval, as being a proceeding in the nature of a lynching, is not only preposterous, but impudent. In the foregoing discussion, and in the illustrations that have been adduced, what I have chiefly endeavored to bring out is the unreasonableness, and the practical absurdity, of the unthinking view which passes current with many for the noble and rational doctrine of freedom of speech and of the press. It may be well to add, in conclusion, a few words on a broader aspect of the matter. Just as religion may be made repulsive and odious by narrowness and bigotry; just as scientific or philosophic thought may be perverted by a spirit of intolerant dogmatism; so a high and inspiring doctrine of human conduct and polity may degenerate into an object of merited contempt when divorced from those considerations upon which its justification rests, and erected into a mere formula, to be followed with superstitious servility. That the absurdities which have been put forward in the name of the doctrine of free speech will actually have the effect of thus degrading and discrediting that doctrine, is not likely; but it is not likely only because common sense and sound feeling may be counted on to keep the folly from spreading. Yet it is the duty of men of light and leading to make clear their own position on the subject whenever it comes conspicuously to the front. They can in no better way serve the permanent interests of the cause of true freedom of speech than by showing, beyond the possibility of mistake, their contempt for the cheap counterfeit of it. In all the clamor that has been set up by the Bouck Whites and the Berkmans and the Upton Sinclairs, has any one pointed to a single doctrine that has been suppressed, a single teacher that has been silenced, a single truth, or alleged truth, that the authorities have endeavored to stifle? Time was when the champions of free speech have had to fight in order that men who had a message to deliver should have a chance to deliver it; what these make-believe apostles and martyrs have to fight for now is a
  • 49. chance to be suppressed. Nobody asks what it was that Bouck White or Becky Edelson wanted to say; what they ask is how he came to be dragged out of a church, or how she came to be arrested for being disorderly. And nobody asks the former question for two reasons—first, that the newspapers freely print what these people have to say; and secondly, that what they have to say is utterly familiar and commonplace. Suppression is not, with them, an obstacle to the spread of their teachings; on the contrary, it is their chief stock-in-trade, their sole claim to the attention of the public. What has elevated the doctrine of freedom of opinion and of speech to the lofty place which it holds in the estimation of mankind is the conviction, slowly acquired through ages of physical and spiritual struggle, that by that freedom can best be served the cause of truth, and hence the advancement of humanity. But with this neither the vulgar stage business of the New York Anarchists of today, nor the crazy appeals to the pistol and the bomb of the Chicago Anarchists of 1886, has anything whatever to do. To identify either with the great historic doctrine of free speech is to debase the intellectual and moral coinage of the race.
  • 51. E IS SOCIALISM COMING? And when the pedants bade us mark What cold mechanic happenings Must come; our souls said in the dark, “Belike; but there are likelier things.” G. K. Chesterton. very historian today owes much to Karl Marx for his development of the “Economic Interpretation of History.” Whatever that theory may fail to explain, it certainly succeeds in explaining the nature and growth of the Socialist movement. When the great attempt at real political and economic democracy made by the French people in their great Revolution had failed and left behind it as a legacy the memory of the Terror and the wars of Napoleon, every nation in Europe felt the reaction. Russia, Austria, Spain and non-industrial Europe generally reacted towards simple absolutism, noble against peasant. But in the countries within the boundary marked out by the industrial revolution, the wealth created by the new machines placed the balance of economic power in the hands of the commercial classes, and so forced the old landed aristocracy to admit them to political power as well. In the meanwhile the first shock of large scale production had widened the gap between the industrial workers and the employing class. Independent artisans were ruined or forced into factories, and in the wake of the new industry there trailed a network of industrial oligarchies which spread until they covered the civilized world. The already enfranchised classes refused to use their power to moderate the harshness of the competitive struggle, honestly believing that any interference with “economic law” could work nothing but ruin and hardship in the end.
  • 52. In view of the facts as they existed in the days of the Communist Manifesto it was practically inevitable that an economist in sympathy with the economically powerless and politically disfranchised masses should interpret history as did the Marxians. In an age of coal, iron and steam (that potent trinity), of large scale production, of capitalistic agriculture, of economic tyranny, of sharpening class divergence and increasing poverty, it seemed that there was no way to realize democracy but to wait until industry had been concentrated into the hands of a few rich men, till the middle class and the free peasantry had been reduced to the proletarian ranks, and till the ever increasing misery of the workers taught them to combine and seize the means of production and distribution by a single revolutionary stroke. Private property could have appeared only as a tool for robbing the workers of the “surplus value” of their labor, religion as an ingenious means of sidetracking revolutionary activities, and patriotism as an excuse for standing armies and protective tariffs. This was a tenable explanation of the world—in 1848! But the world has moved since the day of the Manifesto. Now manhood suffrage is the rule and not the exception. The worst forms of factory serfdom have been ended by legislative and economic changes. The various reform parties of Europe and America and even the Conservatives compete with each other for the workingman’s vote by programs of social amelioration which steadily grow more ambitious every year. Socialism itself has altered in a changing world. The “Revisionist” or common-sense wing of the party has abandoned both the “surplus value” metaphysics, and the prophecy, so happily falsified, of “increasing misery” and “cumulative panics,” and has moderated the class war dogma far enough to permit working hand in hand with the once hated bourgeoisie for immediate reforms. Other Socialists still repeat the old catchwords, but modify them by a process of “interpretation” analogous to that which makes Liberal Christians content to repeat the historic creeds. Of course some revolutionists have looked upon this readjustment with misgivings, and, as a result, we have sporadic and badly led
  • 53. Welcome to our website – the ideal destination for book lovers and knowledge seekers. With a mission to inspire endlessly, we offer a vast collection of books, ranging from classic literary works to specialized publications, self-development books, and children's literature. Each book is a new journey of discovery, expanding knowledge and enriching the soul of the reade Our website is not just a platform for buying books, but a bridge connecting readers to the timeless values of culture and wisdom. With an elegant, user-friendly interface and an intelligent search system, we are committed to providing a quick and convenient shopping experience. Additionally, our special promotions and home delivery services ensure that you save time and fully enjoy the joy of reading. Let us accompany you on the journey of exploring knowledge and personal growth! ebookultra.com