Jquery Reference Guide Jonathan Chaffer Karl Swedberg
Jquery Reference Guide Jonathan Chaffer Karl Swedberg
Jquery Reference Guide Jonathan Chaffer Karl Swedberg
Jquery Reference Guide Jonathan Chaffer Karl Swedberg
1. Jquery Reference Guide Jonathan Chaffer Karl
Swedberg download
https://ebookbell.com/product/jquery-reference-guide-jonathan-
chaffer-karl-swedberg-4440258
Explore and download more ebooks at ebookbell.com
2. Here are some recommended products that we believe you will be
interested in. You can click the link to download.
Jquery Reference Guide Jonathan Chaffer Karl Swedberg
https://ebookbell.com/product/jquery-reference-guide-jonathan-chaffer-
karl-swedberg-4103608
Jquery 14 Reference Guide Chaffer Jonathan Swedberg Karl
https://ebookbell.com/product/jquery-14-reference-guide-chaffer-
jonathan-swedberg-karl-5399094
Jquery Pocket Reference David Flanagan
https://ebookbell.com/product/jquery-pocket-reference-david-
flanagan-2459398
Jquery Pocket Reference Flanagan David
https://ebookbell.com/product/jquery-pocket-reference-flanagan-
david-11793928
3. Jquery For Designers Meap Remy Sharp
https://ebookbell.com/product/jquery-for-designers-meap-remy-
sharp-46601000
Jquery Ui In Action 1st Edition Tj Vantoll
https://ebookbell.com/product/jquery-ui-in-action-1st-edition-tj-
vantoll-46635972
Jquery 2 Recipes Arun K Pande
https://ebookbell.com/product/jquery-2-recipes-arun-k-pande-47823038
Jquery Mobile Web Development Essentials Third Edition Raymond Camden
Andy Matthews
https://ebookbell.com/product/jquery-mobile-web-development-
essentials-third-edition-raymond-camden-andy-matthews-55919534
Jquery Design Patterns 1st Edition Greasidis Thodoris
https://ebookbell.com/product/jquery-design-patterns-1st-edition-
greasidis-thodoris-55921132
6. jQuery Reference Guide
A Comprehensive Exploration of the Popular
JavaScript Library
Jonathan Chaffer
Karl Swedberg
BIRMINGHAM - MUMBAI
8. Credits
Authors
Jonathan Chaffer
Karl Swedberg
Reviewers
Jörn Zaefferer
Dave Methvin
Mike Alsup
Paul Bakaus
Dan Bravender
Senior Acquisition Editor
Douglas Paterson
Development Editor
Nikhil Bangera
Technical Editor
Bansari Barot
Editorial Manager
Dipali Chittar
Project Manager
Patricia Weir
Project Coordinator
Abhijeet Deobhakta
Indexer
Bhushan Pangaonkar
Proofreader
Chris Smith
Production Coordinator
Shantanu Zagade
Cover Designer
Shantanu Zagade
9. About the Authors
Jonathan Chaffer is the Chief Technology Officer of Structure Interactive,
an interactive agency located in Grand Rapids, Michigan. There he oversees
web development projects using a wide range of technologies, and continues to
collaborate on day-to-day programming tasks as well.
In the open-source community, Jonathan has been very active in the Drupal CMS
project, which has adopted jQuery as its JavaScript framework of choice. He is the
creator of the Content Construction Kit, a popular module for managing structured
content on Drupal sites. He is responsible for major overhauls of Drupal’s menu
system and developer API reference.
Jonathan lives in Grand Rapids with his wife, Jennifer.
I would like to thank Jenny, who thinks this is wonderful even if it bores her to tears. I’d
also like to thank Karl for sharing my love for linguistics, producing a book that hopefully is
grammatically immaculate enough to cover up any technical sins.
10. Karl Swedberg is a web developer at Structure Interactive in Grand Rapids,
Michigan, where he spends much of his time implementing design with a focus on
web standards—semantic HTML, well-mannered CSS, and unobtrusive JavaScript.
Before his current love affair with web development, Karl worked as a copy editor,
a high-school English teacher, and a coffee house owner. His fascination with
technology began in the early 1990s when he worked at Microsoft in Redmond,
Washington, and it has continued unabated ever since.
Karl’s other obsessions include photography, karate, English grammar, and
fatherhood. He lives in Grand Rapids with his wife, Sara, and his two children,
Benjamin and Lucia.
I wish to thank my wife, Sara, for her steadfast love and support during my far-flung
adventures into esoteric nonsense. Thanks also to my two delightful children, Benjamin
and Lucia. Jonathan Chaffer has my deepest respect and gratitude for his willingness
to write this book with me and to explain the really difficult aspects of programming in a
gentle manner when I just don’t get it. Finally, I wish to thank John Resig for his brilliant
JavaScript library and his ongoing encouragement for the book, as well as Rey Bango,
Brandon Aaron, Klaus Hartl, Jörn Zaefferer, Dave Methvin, Mike Alsup, Yehuda Katz,
Stefan Petre, Paul Bakaus, Michael Geary, Glen Lipka, and the many others who have
provided help and inspiration along the way.
11. About the Reviewers
Jörn Zaefferer is a software developer and a consultant from Köln, Germany. He is
currently working at Maxence Integration Technologies GmbH. His work is centered
on developing web-based applications as JSR-168 portlets in JEE environments,
mostly Websphere Portal 5.1 based. He is currently working on a project based on
JSF and Spring.
Dave Methvin has more than 25 years of software development experience in
both the Windows and UNIX environments. His early career focused on embedded
software in the fields of robotics, telecommunications, and medicine. Later, he
moved to PC-based software projects using C/C++ and web technologies.
Dave also has more than 20 years of experience in computer journalism. He was
Executive Editor at PC Tech Journal and Windows Magazine, covering PC and Internet
issues; his how-to columns on JavaScript offered some of the first cut-and-paste
solutions to common web page problems. He was also a co-author of the book
Networking Windows NT (John Wiley & Sons, 1997).
Currently, Dave is Chief Technology Officer at PC Pitstop, a website that helps
users fix and optimize the performance of their computers. He is also active in the
jQuery community.
Mike Alsup is a Senior Software Developer at ePlus where he works on J2EE and
web development projects. He is a graduate from Potsdam College and has been
serving the software industry since 1989. Mike lives in Palmyra, NY with his wife,
Diane, and their three sons.
His jQuery plug-ins can be found at http://malsup.com/jquery/.
12. Paul Bakaus is a programmer and core developer living in Germany. His work
with jQuery has been focused on transforming jQuery into a high-speed library
capable of handling difficult large-scale rich interface operations. He was largely
responsible for creating the jQuery Dimensions plug-in and he now works together
with Stefan Petre on the rich effects and components library Interface. Paul is
currently involved in creating a JavaScript multiplayer game featuring jQuery.
Dan Bravender has been working with open-source software for over 10 years. His
fondest memories are of staying up all night to install and compile Linux in college
with his roommate. He has collected a massive collection of German board games.
When not playing board games, he enjoys playing soccer and hockey and studying
Korean and Chinese etymology. He misses working with Karl and Jon and is very
proud of all the hard work that they put into this book.
13. Table of Contents
Preface 1
Chapter 1: Anatomy of a jQuery Script 5
A Dynamic Table of Contents 5
Obtaining jQuery 7
Setting Up the HTML Document 7
Writing the jQuery Code 10
Script Dissection 11
Selector Expressions 11
DOM Traversal Methods 11
DOM Manipulation Methods 12
Event Methods 12
Effect Methods 13
AJAX Methods 13
Miscellaneous Methods 13
Plug-In API 14
Summary 14
Chapter 2: Selector Expressions 17
CSS Selectors 17
Element: T 17
ID: #myid 17
Class: .myclass 18
Descendant: E F 19
Child: E > F 19
Adjacent Sibling: E + F 20
General Sibling: E ~ F 21
Multiple Elements: E,F,G 22
Nth Child (:nth-child(n)) 22
First Child (:first-child) 23
14. Table of Contents
[ ii ]
Last Child (:last-child) 23
Only Child :only-child 24
Not :not(s) 24
Empty :empty 24
Universal: * 25
XPath Selectors 25
Descendant: E//F 25
Child: E/F 26
Parent: E/.. 26
Contains: [F] 27
Attribute Selectors 27
Has Attribute: [@foo] 28
Attribute Value Equals: [@foo=bar] 28
Attribute Value Does Not Equal: [@foo!=bar] 29
Attribute Value Begins: [@foo^=bar] 29
Attribute Value Ends: [@foo$=bar] 30
Attribute Value Contains: [@foo*=bar] 30
Form Selectors 30
Custom Selectors 31
Even Element (:even) Odd Element (:odd) 31
Nth Element (:eq(n), :nth(n)) 32
Greater Than :gt(n) 32
Less Than : lt(n) 33
First :first 33
Last :last 33
Parent :parent 34
Contains :contains(text) 34
Visible :visible 35
Hidden :hidden 35
Chapter 3: DOM Traversal Methods 37
The jQuery Factory Function 37
$() 38
Filtering Methods 40
.filter() 40
.not() 42
.contains() 43
.eq() 44
.lt() 45
.gt() 46
Tree Traversal Methods 47
18. Table of Contents
[ vi ]
Chapter 8: Miscellaneous Methods 169
Setup Methods 169
$.browser 169
$.noConflict() 170
DOM Element Methods 171
.length 171
.size() 172
.get() 172
.index() 173
Collection Manipulation 174
.each() 174
$.grep() 176
$.map() 177
$.merge() 179
$.unique() 180
$.extend() 181
$.trim() 182
Chapter 9: Plug-In API 183
Using a Plug-in 183
Developing a Plug-in 184
Object Method 184
Global Function 186
Selector Expression 188
Easing Style 189
Example: Maintaining Multiple Event Logs 192
Summary 194
Chapter 10: Dimensions Plug-In 195
Size Methods 195
.height() 196
.width() 197
.innerHeight() 199
.innerWidth() 200
.outerHeight() 201
.outerWidth() 202
Position Methods 203
.scrollTop() 204
.scrollTop(value) 204
.scrollLeft() 205
19. Table of Contents
[ vii ]
.scrollLeft(value) 206
.offset() 207
.position() 212
Chapter 11: Form Plug-In 215
AJAX Form Submission 215
.ajaxSubmit() 215
.ajaxForm() 217
.ajaxFormUnbind() 223
Retrieving Form Values 223
.formToArray() 223
.formSerialize() 224
.fieldSerialize() 225
.fieldValue() 226
Form Manipulation 228
.clearForm() 228
.clearFields() 229
.resetForm() 230
Appendix A: Online Resources 233
jQuery Documentation 233
JavaScript Reference 234
JavaScript Code Compressors 235
(X)HTML Reference 235
CSS Reference 235
XPath Reference 236
Useful Blogs 236
Web Development Frameworks Using jQuery 238
Appendix B: Development Tools 239
Tools for Firefox 239
Tools for Internet Explorer 240
Tools for Safari 241
Other Tools 241
Index 243
21. Preface
jQuery is a powerful, yet easy-to-use JavaScript library that helps web developers
and designers add dynamic, interactive elements to their sites, smoothing out
browser inconsistencies and greatly reducing development time. In jQuery Reference
Guide, you can investigate this library's features in a thorough, accessible format.
This book offers an organized menu of every jQuery method, function, and selector.
Entries are accompanied by detailed descriptions and helpful recipes that will assist
you in getting the most out of jQuery and avoiding the pitfalls commonly associated
with JavaScript and other client-side languages. If you're still hungry for more,
the book shows you how to cook up your own extensions with jQuery's elegant
plug-in architecture.
You'll discover the untapped possibilities that jQuery makes available and hone your
skills as you return to this guide time and again.
Demos of examples in this book are available at:
http:book.learningjquery.com.
What This Book Covers
In Chapter 1 we'll begin by dissecting a working jQuery example. This script will
serve as a roadmap for this book, directing you to the chapters containing more
information on particular jQuery capabilities.
The heart of the book is a set of reference chapters that allow you to quickly look up
the details of any jQuery method. Chapter 2 lists every available selector for finding
page elements.
Chapter 3 builds on the previous chapter with a catalog of jQuery methods for finding
page elements.
22. Preface
[ ]
Chapter 4 describes every opportunity for inspecting and modifying the HTML
structure of a page.
Chapter 5 details each event that can be triggered and reacted to by jQuery.
Chapter 6 defines the range of animations built into jQuery, as well as the toolkit
available for building your own.
Chapter 7 lists the ways in which jQuery can initiate and respond to server
communication without refreshing the page.
Chapter 8 covers the remaining capabilities of the jQuery library that don't neatly fit
into the other categories.
In the final three chapters, you'll dive into the extension mechanisms jQuery makes
available. Chapter 9 reveals four major ways to enhance jQuery's already robust
capabilities using a plug-in.
Chapter 10 walks you through the advanced measurement tools available in the
popular Dimensions plug-in.
Chapter 11 empowers you to bring AJAX technology and HTML forms together, a
process which is made easy by the Form plug-in.
Appendix A provides a handful of informative websites on a wide range of topics
related to jQuery, JavaScript, and web development in general.
Appendix B recommends a number of useful third-party programs and utilities for
editing and debugging jQuery code within your personal development environment.
Who is This Book For?
This book is for web designers who want to create interactive elements for their
designs, and for developers who want to create the best user interface for their
web applications.
The reader will need the basics of HTML and CSS, and should be comfortable with
the syntax of JavaScript. No knowledge of jQuery is assumed, nor is experience with
any other JavaScript libraries required.
23. Preface
[ ]
Conventions
In this book, you will find a number of styles of text that distinguish between
different kinds of information. Here are some examples of these styles, and an
explanation of their meaning.
There are three styles for code. Code words in text are shown as follows: Taken
together, $() and .addClass() are enough for us to accomplish our goal of
changing the appearance of the poem text.
A block of code will be set as follows:
$(document).ready(function() {
$('span:contains(language)').addClass('emphasized');
});
When we wish to draw your attention to a particular part of a code block, the
relevant lines or items will be made bold:
$(document).ready(function() {
$('a[@href$=.pdf]').addClass('pdflink');
});
New terms and important words are introduced in a bold-type font. Words that you
see on the screen, in menus or dialog boxes for example, appear in our text like this:
The next step is to run those tests by clicking the All button.
Important notes appear in a box like this.
Tips and tricks appear like this.
Reader Feedback
Feedback from our readers is always welcome. Let us know what you think about
this book, what you liked or may have disliked. Reader feedback is important for us
to develop titles that you really get the most out of.
To send us general feedback, simply drop an email to feedback@packtpub.com,
making sure to mention the book title in the subject of your message.
24. Preface
[ ]
If there is a book that you need and would like to see us publish, please send
us a note in the SUGGEST A TITLE form on www.packtpub.com or
email suggest@packtpub.com.
If there is a topic that you have expertise in and you are interested in either writing
or contributing to a book, see our author guide on www.packtpub.com/authors.
Customer Support
Now that you are the proud owner of a Packt book, we have a number of things to
help you to get the most from your purchase.
Downloading the Example Code for the Book
Visit http://www.packtpub.com/support, and select this book from the list of titles
to download any example code or extra resources for this book. The files available
for download will then be displayed.
The downloadable files contain instructions on how to use them.
Errata
Although we have taken every care to ensure the accuracy of our contents, mistakes
do happen. If you find a mistake in one of our books—maybe a mistake in text or
code—we would be grateful if you would report this to us. By doing this you can
save other readers from frustration, and help to improve subsequent versions of
this book. If you find any errata, report them by visiting http://www.packtpub.
com/support, selecting your book, clicking on the Submit Errata link, and entering
the details of your errata. Once your errata are verified, your submission will be
accepted and the errata added to the list of existing errata. The existing errata can be
viewed by selecting your title from http://www.packtpub.com/support.
Questions
You can contact us at questions@packtpub.com if you are having a problem with
some aspect of the book, and we will do our best to address it.
25. Anatomy of a jQuery Script
He's got a brand new start
Now he's a happy guy
—Devo,
Happy Guy
A typical jQuery script uses a wide assortment of the methods that the library
offers. Selectors, DOM manipulation, event handling, and so forth come into play
as required by the task at hand. In order to make the best use of jQuery, we need to
keep in mind the wide range of capabilities it provides.
This book will itemize every method and function found in the jQuery library. Since
there are many methods and functions to sort through, it will be useful to know what
the basic categories of methods are, and how they come into play within a jQuery
script. Here we will see a fully functioning script, and examine how the different
aspects of jQuery are utilized in each part of the script.
A Dynamic Table of Contents
As an example of jQuery in action, we'll build a small script that will dynamically
extract the headings from an HTML document and assemble them into a table of
contents for that page.
26. Anatomy of a jQuery Script
[ ]
Our table of contents will be nestled on the top right corner of the page:
We'll have it collapsed initially as shown above, but a click will expand it to
full height:
27. Chapter 1
[ ]
At the same time, we'll add a feature to the main body text. The introduction of the
text on the page will not be initially loaded, but when the user clicks on the word
Introduction, the introductory text will be inserted in place from another file:
Before we reveal the script that performs these tasks, we should walk through the
environment in which the script resides.
Obtaining jQuery
The official jQuery website (http://jquery.com/) is always the most up-to-date
resource for code and news related to the library. To get started, we need a copy
of jQuery, which can be downloaded right from the home page of the site. Several
versions of jQuery may be available at any given moment; the latest uncompressed
version will be most appropriate for us.
No installation is required for jQuery. To use jQuery, we just need to place it on
our site in a public location. Since JavaScript is an interpreted language, there is
no compilation or build phase to worry about. Whenever we need a page to have
jQuery available, we will simply refer to the file's location from the HTML document.
Setting Up the HTML Document
There are three sections to most examples of jQuery usage— the HTML document
itself, CSS files to style it, and JavaScript files to act on it. For this example, we'll use a
page containing the text of a book:
?xml version=1.0 encoding=UTF-8 ?
!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
html xmlns=http://www.w3.org/1999/xhtml xml:lang=en lang=en
head
28. Anatomy of a jQuery Script
[ ]
meta http-equiv=Content-Type content=text/html;
charset=utf-8/
titleDoctor Dolittle/title
link rel=stylesheet href=dolittle.css type=text/css /
script src=jquery.js type=text/javascript/script
script src=dolittle.js type=text/javascript/script
/head
body
div id=container
h1Doctor Dolittle/h1
div class=authorby Hugh Lofting/div
div id=introduction
h2a href=introduction.htmlIntroduction/a/h2
/div
div id=content
h2Puddleby/h2
pONCE upon a time, many years ago when our grandfathers
were little children--there was a doctor; and his name was
Dolittle-- John Dolittle, M.D. quot;M.D.quot; means
that he was a proper doctor and knew a whole lot.
/p
!-- More text follows... --
/div
/div
/body
/html
The actual layout of files on the server does not matter. References from
one file to another just need to be adjusted to match the organization
we choose. In most examples in this book, we will use relative paths to
reference files (../images/foo.png) rather than absolute paths (/
images/foo.png). This will allow the code to run locally without the
need for a web server.
The stylesheet is loaded immediately after the standard head elements. Here are
the portions of the stylesheet that affect our dynamic elements:
/* -----------------------------------
Page Table of Contents
-------------------------------------- */
#page-contents {
position: absolute;
text-align: left;
29. Chapter 1
[ ]
top: 0;
right: 0;
width: 15em;
border: 1px solid #ccc;
border-top-width: 0;
border-right-width: 0;
background-color: #e3e3e3;
}
#page-contents h3 {
margin: 0;
padding: .25em .5em .25em 15px;
background: url(arrow-right.gif) no-repeat 0 2px;
font-size: 1.1em;
cursor: pointer;
}
#page-contents h3.arrow-down {
background-image: url(arrow-down.gif);
}
#page-contents a {
display: block;
font-size: 1em;
margin: .4em 0;
font-weight: normal;
}
#page-contents div {
padding: .25em .5em .5em;
display: none;
background-color: #efefef;
}
/* -----------------------------------
Introduction
-------------------------------------- */
.dedication {
margin: 1em;
text-align: center;
border: 1px solid #555;
padding: .5em;
}
After the stylesheet is referenced, the JavaScript files are included. It is important that
the script tag for the jQuery library be placed before the tag for our custom scripts;
otherwise, the jQuery framework will not be available when our code attempts to
reference it.
30. Anatomy of a jQuery Script
[ 10 ]
Writing the jQuery Code
Our custom code will go in the second, currently empty, JavaScript file which
we included from the HTML using script src=dolittle.js type=text/
javascript/script. Despite how much it accomplishes, the script is
fairly short:
jQuery.fn.toggleNext = function() {
this.toggleClass('arrow-down')
.next().slideToggle('fast');
};
$(document).ready(function() {
$('div id=page-contents/div')
.prepend('h3Page Contents/h3')
.append('div/div')
.prependTo('body');
$('#content h2').each(function(index) {
var $chapterTitle = $(this);
var chapterId = 'chapter-' + (index + 1);
$chapterTitle.attr('id', chapterId);
$('a/a').text($chapterTitle.text())
.attr({
'title': 'Jump to ' + $chapterTitle.text(),
'href': '#' + chapterId
})
.appendTo('#page-contents div');
});
$('#page-contents h3').click(function() {
$(this).toggleNext();
});
$('#introduction h2 a').click(function() {
$('#introduction').load(this.href);
return false;
});
});
We now have a dynamic table of contents that brings users to the relevant portion of
the text, and an introduction that is loaded on demand.
31. Chapter 1
[ 11 ]
Script Dissection
This script has been chosen specifically because it illustrates the widespread
capabilities of the jQuery library. Now that we've seen the code as a whole, we can
identify the categories of methods used therein.
We will not discuss the operation of this script in much detail here, but a
similar script is presented as a tutorial on the Learning jQuery web log:
http://www.learningjquery.com/2007/06/
automatic-page-contents.
Selector Expressions
Before we can act on an HTML document, we need to locate the relevant portions. In
our script, we sometimes use a simple approach to finding an element:
$('#introduction')
This expression creates a new jQuery object that references the element with the ID
introduction. On the other hand, sometimes we require a more intricate selector:
$('#introduction h2 a')
Here we produce a jQuery object potentially referring to many elements. Elements
are included if they are anchor tags, but only if they are descendants of h2
elements that are themselves children of an element with the ID introduction.
These selector expressions can be as simple or complex as we need. Chapter 2 will
enumerate all of the selectors available to us and how they can be combined.
DOM Traversal Methods
Sometimes we have a jQuery object that already references a set of DOM elements,
but we need to perform an action on a different, related set of elements. In these
cases, DOM traversal methods are useful. We can see this in part of our script:
this.toggleClass('arrow-down')
.next()
.slideToggle('fast');
32. Anatomy of a jQuery Script
[ 12 ]
Because of the context of this piece of code, the keyword this refers to a jQuery
object (it often refers instead to a DOM element). In our case, this jQuery object is
in turn pointing to the h3 heading of the table of contents. The .toggleClass
method call manipulates this heading element. The subsequent .next()
operation changes the element we are working with, though, so that the following
.slideToggle method call acts on the div containing the table of contents rather
than its header. The methods that allow us to freely move about the DOM tree like
this are listed in Chapter 3.
DOM Manipulation Methods
Finding elements is not enough; we want to be able to change them as well. Such
changes can be as straightforward as changing a single attribute:
$chapterTitle.attr('id', chapterId);
Here we modify the ID of the matched element on the fly.
Sometimes the changes are further-reaching, on the other hand:
$('div id=page-contents/div')
.prepend('h3Page Contents/h3')
.append('div/div')
.prependTo('body');
This part of the script illustrates that the DOM manipulation methods can not only
alter elements in place, but also remove, shuffle, and insert them. These lines add a
new heading at the beginning of div id=page-contents, insert another div
container at the end of it, and place the whole thing at the beginning of the document
body. Chapter 4 will detail these and many more ways to modify the DOM tree.
Event Methods
Even when we can modify the page at will, our pages will sit in place, unresponsive.
We need event methods to react to user input, making our changes at the
appropriate time:
$('#introduction h2 a').click(function() {
$('#introduction').load(this.href);
return false;
});
In this snippet we register a handler that will execute each time the selected anchor
tag is clicked. The click event is one of the most common ones observed, but there are
many others; the jQuery methods that interact with them are discussed in Chapter 5.
33. Chapter 1
[ 13 ]
Chapter 5 also discusses a very special event method, .ready:
$(document).ready(function() {
// ...
});
This method allows us to register behavior that will occur immediately when the
structure of the DOM is available to our code—even before the images have loaded.
Effect Methods
The event methods allow us to react to user input; the effect methods let us do this
with style. Instead of immediately hiding and showing elements, we can do so with
an animation:
this.toggleClass('arrow-down')
.next()
.slideToggle('fast');
This method performs a fast sliding transition on the element, alternately hiding and
showing it with each invocation. The built-in effect methods are listed in Chapter 6,
as is the way to create new ones.
AJAX Methods
Many modern websites employ techniques to load content when requested without
a page refresh; jQuery allows us to accomplish this with ease. The AJAX Methods
initiate these content requests and allow us to monitor their progress:
$('#introduction h2 a').click(function() {
$('#introduction').load(this.href);
return false;
});
Here the .load method allows us to get another HTML document from the server
and insert it in the current document, all with one line of code. This and more
sophisticated mechanisms of retrieving information from the server are listed
in Chapter 7.
Miscellaneous Methods
Some methods are harder to classify than others. The jQuery library incorporates
several miscellaneous methods that serve as shorthand for common
JavaScript idioms.
34. Anatomy of a jQuery Script
[ 14 ]
Even basic tasks like iteration are simplified by jQuery:
$('#content h2').each(function(index) {
// ...
});
The .each method seen here steps through the matched elements in turn,
performing the enclosed code on all of matched elements. In this case, the method
helps us to collect all of the headings on the page so that we can assemble a complete
table of contents. More helper functions such as this can be found in Chapter 8.
Plug-In API
We need not confine ourselves to built-in functionality either. The plug-in API that
is part of jQuery allows us to augment the capabilities already present with new ones
that suit our needs. Even in the small script we've written here, we've found the use
for a plug‑in:
jQuery.fn.toggleNext = function() {
this.toggleClass('arrow-down')
.next().slideToggle('fast');
};
This code defines a new .toggleNext jQuery method that slides the following
element open and shut. We can now call our new method later when needed:
$('#page-contents h3').click(function() {
$(this).toggleNext();
});
Whenever code could be reused outside the current script, it might do well as a
plug‑in. Chapter 9 will cover the plug-in API used to build these extensions.
35. Chapter 1
[ 15 ]
Summary
We've now seen a complete, functional jQuery-powered script. This example,
though small, brings a significant amount of interactivity and usability to the page.
The script has illustrated the major types of tools offered by jQuery, as well. We've
observed how the script finds items in the DOM and changes them as necessary.
We've witnessed response to user action, and animation to give feedback to the user
after the action. We've even seen how to pull information from the server without a
page refresh, and how to teach jQuery brand new tricks in the form of plug-ins.
We'll be stepping through each function, method, and selector expression in the
jQuery library now, chapter by chapter. In illustrating many of them, a customized
logging function will aid our examples. This .log method prints text to the screen in
a useful context; we'll dissect it as an example of a plug-in at the end of Chapter 9.
Each method will be introduced with a summary of its syntax and a list of its
parameters and return value. Then we will offer a discussion, which will provide
examples where applicable. For further reading about any method, consult the online
resources listed in Appendix A.
37. Selector Expressions
You got me lookin' up high
You got me searchin' down low
—Devo,
Jerkin' Back 'n' Forth
Borrowing from CSS 1–3 and basic XPath, and then adding its own, jQuery offers a
powerful set of selector expressions for matching a set of elements in a document. In
this chapter, we'll examine every selector expression that jQuery makes available
in turn.
CSS Selectors
The following selectors are based on the CSS 1–3, as outlined by the W3C. For more
information about the specifications, visit http://www.w3.org/Style/CSS/#specs.
Element: T
All elements that have a tag name of T.
Example
1. $('div'): selects all elements with a tag name of div in the document
2. $('em'): selects all elements with a tag name of em in the document
Description
jQuery uses JavaScript's getElementsByTagName() function for tag-name selectors.
ID: #myid
The unique element with an ID equal to myid.
38. Selector Expressions
[ 18 ]
Examples
1. $('#myid'): selects the unique element with id='myid', regardless of its
tag name
2. $('p#myid'): selects a single paragraph with an id of 'myid'; in other
words, the unique element p id='myid'
Description
Each id value must be used only once within a document. If more than one element
has been assigned the same id, queries that use that id will only select the first
matched element in the DOM.
It might not be immediately clear why someone might want to specify a tag name
associated with a particular id, since that id needs to be unique anyway. However,
some situations in which parts of the DOM are user-generated may require a more
specific expression to avoid false positives. Furthermore, when the same script is run
on more than one page, it might be necessary to identify the id's element, since the
pages could be associating the same id with different elements. For example, Page A
might have h1 id='title' while Page B has h2 id='title'.
For a plain id selector such as example 2 above, jQuery uses the JavaScript function
getElementById(). If the script's execution speed is paramount, the plain id selector
should be used.
Class: .myclass
All elements that have a class of myclass.
Examples
1. $('.myclass'): selects all elements that have a class of myclass
2. $('p.myclass'): selects all paragraphs that have a class of myclass
3. $('.myclass.otherclass'): selects all elements that have a class of
myclass and otherclass
Description
In terms of speed, example 2 is generally preferable to example 1 (if we can limit
the query to a given tag name) because it first uses the native JavaScript function
getElementsByTagName() to filter its search, and then looks for the class within
the matched subset of DOM elements. Conversely, there is currently no native
getElementsByClassName() for jQuery to use, so using a bare class name forces
jQuery to match it against every element in the DOM. The difference in speed varies,
however, with the complexity of the page and the number of DOM elements.
39. Chapter 2
[ 19 ]
As always, remember that development time is typically the most valuable resource.
Do not focus on optimization of selector speed unless it is clear that performance
needs to be improved.
As a CSS selector, the multiple-class syntax of example 3 is supported by all modern
web browsers, but not by Internet Explorer versions 6 and below, which makes the
syntax especially handy for applying styles cross-browser through jQuery.
Descendant: E F
All elements matched by F that are descendants of an element matched by E.
Examples
1. $('#container p'): selects all elements matched by p that are
descendants of an element that has an id of container
2. $('a img'): selects all elements matched by img that are descendants of an
element matched by a
Description
A descendant of an element could be a child, grandchild, great-grandchild,
and so on, of that element. For example, in the following HTML, the img
element is a descendant of the span, p, div id=inner, and
div id=container elements:
div id=container
div id=inner
p
spanimg src=example.jpg alt= //span
/p
/div
/div
Child: E F
All elements matched by F that are children of an element matched by E.
Examples
1. $('li ul'): selects all elements matched by ul that are children of an
element matched by li
2. $('p code'): selects all elements matched by code that are children of an
element matched by p
40. Selector Expressions
[ 20 ]
Description
As a CSS selector, the child combinator is supported by all modern web browsers
including Safari, Mozilla/Firefox, and Internet Explorer 7, but notably not by
Internet Explorer versions 6 and below. Example 1 is a handy way to select all nested
unordered lists (i.e. excepting the top level).
The child combinator can be thought of as a more specific form of the (single-space)
descendant combinator in that it selects only first-level descendants. Therefore, in the
following HTML, the img element is a child only of the span element.
div id=container
div id=inner
p
spanimg src=example.jpg alt= //span
/p
/div
/div
Adjacent Sibling: E + F
All elements matched by F that immediately follow, and have the same parent as, an
element matched by E.
Examples
1. $('ul + p'): selects all elements by p (paragraph) that immediately follow
a sibling element matched by ul (unordered list)
2. $('strong + em'): selects all elements matched by em that immediately
follow a sibling element matched by strong
Description
One important point to consider with both the + combinator and the ~ combinator
(covered next) is that they only select siblings. Consider the following HTML:
div id=container
ul
li/li
li/li
/ul
p
img/
/p
/div
41. Chapter 2
[ 21 ]
$('ul + p') selects p because it immediately follows ul and the two elements
share the same parent, div id=container.
$('ul + img') selects nothing because (among other reasons) ul is one level
higher in the DOM tree than img.
$('li + img') selects nothing because, even though li and img are on the same
level in the DOM tree, they do not share the same parent.
General Sibling: E ~ F
All elements matched by F that follow, and have the same parent as, an element
matched by E.
Examples
1. $('p ~ ul'): selects all elements matched by ul that follow a sibling
element matched by p
2. $('code ~ code'): selects all elements matched by code that follow a
sibling element matched by code
Description
One important point to consider with both the + combinator and the ~ combinator
is that they only select siblings. The notable difference between the two is their
respective reach. While the + combinator reaches only to the immediately following
sibling element, the ~ combinator extends that reach to all following sibling elements.
Consider the following HTML:
ul
li class=first/li
li class=second/li
li class=third/li
/ul
ul
li class=fourth/li
li class=fifth/li
li class=sixth/li
/ul
$('li.first ~ li') selects li class=second and li class=third.
$('li.first + li') selects li class=second.
42. Selector Expressions
[ 22 ]
Multiple Elements: E,F,G
Selects all elements matched by selector expressions E, F, or G.
Examples
1. $('code, em, strong'): selects all elements matched by code or em or
strong
2. $('p strong, .myclass'): selects all elements matched by strong that
are descendants of an element matched by p as well as all elements that
have a class of myclass
Description
This comma (,) combinator is an efficient way to select disparate elements. An
alternative to this combinator is the .add() method described in Chapter 3.
Nth Child (:nth-child(n))
All elements that are the nth
child of their parent.
Examples
1. $('li:nth-child(2)'): selects all elements matched by li that are the
second child of their parent
2. $('p:nth-child(5)'): selects all elements matched by p that are the fifth
child of their parent
Description
Because jQuery's implementation of :nth-child(n) is strictly derived from the CSS
specification, the value of n is 1-based, meaning that the counting starts at 1. For all
other selector expressions, however, jQuery follows JavaScript's 0-based counting.
Therefore, given a single ul containing two lis, $('li:nth-child(1)') selects
the first li while $('li:nth(1)') selects the second.
Because the two look so similar, the :nth-child(n) pseudo-class is easily confused
with :nth(n), even though, as we have just seen, the two can result in dramatically
different matched elements. With :nth-child(n), all children are counted,
regardless of what they are, and the specified element is selected only if it matches
the selector attached to the pseudo-class. With :nth(n) only the selector attached
to the pseudo-class is counted, not limited to children of any other element, and the
nth one is selected. To demonstrate this distinction, let's examine the results of a few
selector expressions given the following HTML:
div
h2/h2
43. Chapter 2
[ 23 ]
p/p
h2/h2
p/p
p/p
/div
$('p:nth(1)') selects the second p, because numbering for :nth(n) starts with 0.
$('p:nth-child(1)') selects nothing, because there is no p element that is the
first child of its parent.
$('p:nth(2)') selects the third p.
$('p:nth-child(2)') selects the first p, because it is the second child of its parent.
In addition to taking an integer, :nth-child(n) can take even or odd. This makes it
especially useful for table-row striping solutions when more than one table appears
in a document. Again, given the HTML snippet above:
$('p:nth-child(even)') selects the first and third p, because they are children 2
and 4 (both even numbers) of their parent.
First Child (:first-child)
All elements that are the first child of their parent:
Examples
1. $('li:first-child'): selects all elements matched by li that are the
first child of their parent
2. $(strong:first-child'): selects all elements matched by strong that
are the first child of their parent
Description
The :first-child pseudo-class is shorthand for :nth-child(1). For more
information on :X-child pseudo-classes, see the discussion for :nth-child(n).
Last Child (:last-child)
All elements that are the last child of their parent.
Examples
1. $('li:last-child'): selects all elements matched by li that are the last
child of their parent
2. $('code:last-child'): selects all elements matched by code that are the
last child of their parent
44. Selector Expressions
[ 24 ]
Description
For more information on :X-child pseudo-classes, see the discussion for
:nth-child(n).
Only Child :only-child
All elements that are the only child of their parent.
Examples
1. $(':only-child'): selects all elements that are the only child of their parent
2. $('code:only-child'): selects all elements matched by code that are the
only child of their parent
Not :not(s)
All elements that do not match selector s.
Examples
1. $('li:not(.myclass)'): selects all elements matched by li that do not
have class=myclass
2. $('li:not(:last-child)'): selects all elements matched by li that are
not the last child of their parent element
Empty :empty
All elements that have no children (including text nodes).
Examples
1. $(':empty'): selects all elements that have no children
2. $('p:empty'): selects all elements matched by p that have no children
Description
The W3C recommends that the p element have at least one child node, even if
that child is merely text (see http://www.w3.org/TR/html401/struct/text.
html#edef-P). Some other elements, on the other hand, are empty (i.e. have no
children) by definition: input, img, br, and hr, for example.
One important thing to note with :empty (and :parent) is that child elements include
text nodes.
45. Chapter 2
[ 25 ]
Universal: *
All elements.
Examples
1. $('*'): selects all elements in the document
2. $('p *'): selects all elements that are children of a paragraph element
Description
The * selector is especially useful when combined with other elements to form a
more specific selector expression.
XPath Selectors
Modeled after a file system's directory-tree navigation, XPath selector expressions
provide an alternative way to access DOM elements. Although XPath was developed
as a selector language for XML documents, jQuery makes a basic subset of its
selectors available for use in XML and HTML documents alike.
For more information about XPath 1.0, visit the specification at the W3C:
http://www.w3.org/TR/xpath.
Descendant: E//F
All elements matched by F that are descendants of an element matched by E.
Examples
1. $('div//code'): selects all elements matched by code that are
descendants of an element matched by div
2. $('//p//a'): selects all elements matched by a that are descendants of an
element matched by p
Description
This XPath descendant selector works the same as the corresponding CSS descendant
selector ($('E F')) except that the XPath version can specify that it is to start at the
document root, which could be useful when querying an XML document.
In example 2, the initial //p tells jQuery to start at the document root and match
all p elements that are descendants of it. Keep in mind that if this selector
expression follows a DOM traversal method such as .find(), this syntax will not
select anything because the document root cannot be a child of anything else. Since
jQuery allows free mixing of CSS and XPath selectors, the initial // is redundant and,
therefore, can be omitted.
46. Selector Expressions
[ 26 ]
Child: E/F
All elements matched by F that are children of an element matched by E.
Examples
1. $('div/p'): selects all elements matched by p that are children of an
element matched by div
2. $('p/a'): selects all elements matched by a that are children of an element
matched by p
3. $('/docroot/el'): selects all elements matched by el that are children
of an element matched by docroot, as long as docroot is actually at the
document root
Description
The XPath child selector, $('E/F'), is an alternative to the CSS child selector,
$('E F'). If the selector expression begins with a single slash, as is the case in
example 3, the selector immediately following the slash must be at the document
root. Beginning with a single slash is not recommended in HTML documents, since
it always must be followed with body for the expression to match any elements on
the page. For XML documents, however, it might be useful to identify a particular
element or attribute at the document root.
Parent: E/..
All elements that are parents of an element matched by E.
Examples
1. $('.myclass/..'): selects the parent element of all elements that have a
class of myclass
2. $('.myclass/../'): selects all elements that are children of the parent of
an element that has a class of myclass. In other words, it selects all elements
that have a class of myclass, along with their sibling elements
3. $('.myclass/../p'): selects all elements matched by p that are children
of the element that has a class of myclass
Description
Let's look at some sample HTML to help understand this one:
div
p id=firstp/p
div id=subdiv/div
p id=secondp
47. Chapter 2
[ 27 ]
span class=myclass/span
/p
/div
div
p/p
/div
$('span.myclass/..') selects p id=secondp, because it is the parent of span
class=myclass.
$('#firstp/../') selects p id=firstp, div id=subdiv, and p
id=secondp, because the selector (a) starts with p id=firstp, (b) traverses
up one level in the DOM tree (to the first top-level div element), and (c) selects all
children of that div.
$('.myclass/../../p') selects p id=firstp and p id=secondp, because
the selector (a) starts with span class=myclass, (b) traverses up two levels in
the DOM tree (to the first top-level div element), and (c) selects all p elements
that are children of that div.
Contains: [F]
All elements that contain an element matched by F.
Examples
1. $('div[p]'): selects all elements matched by div that contain an element
matched by p
2. $('p[.myclass]'): selects all elements matched by p that contain an
element with a class of myclass
Description
This selector is like the reverse of the descendant selector (either E//F or E F), in that
it selects all elements that have a descendant element matched by F instead of all
elements matched by F that are descendants of some other element.
The XPath contains selector is not to be confused with the CSS attribute selector,
which shares this syntax. jQuery uses the XPath-style expression for attribute
selectors too, as discussed in the Attribute Selectors section below.
Attribute Selectors
Because jQuery supports both CSS and XPath-style expressions and the two conflict
in their use of square brackets, jQuery adopts the XPath notation for attribute
selectors, beginning them with the @ symbol.
48. Selector Expressions
[ 28 ]
When using any of the following attribute selectors, we should account for attributes
that have multiple, space-separated values. Since these selectors see attribute values
as a single string, this selector, for example, $('[a@rel=nofollow]'), will select
a rel=nofollow href=example.htmlSome text/a but not
a rel=nofollow self href=example.htmlSome text/a.
Attribute values in selector expressions can be written as bare words or surrounded
by quotation marks. Therefore, the following variations are equally correct:
bare words: $('[a@rel=nofollow self]')
double quotes inside single quotes: $('[a@rel=nofollow self]')
single quotes inside double quotes: $([a@rel='nofollow self'])
escaped single quotes inside single quotes:
$('[a@rel='nofollow self']')
escaped double quotes inside double quotes:
$([a@rel=nofollow self])
The variation we choose is generally a matter of style or convenience.
Has Attribute: [@foo]
All elements that have the foo attribute.
Examples
1. $('a[@rel]'): selects all elements matched by a that have a rel attribute
2. $('p[@class]'): selects all elements matched by p that have a
class attribute
Description
For more information on this attribute selector, see the introduction to Attribute
Selectors above.
Attribute Value Equals: [@foo=bar]
Elements that have the foo attribute with a value exactly equal to bar.
Examples
1. $('a[@rel=nofollow]'): selects all elements matched by a that have a
rel value exactly equal to nofollow
2. $('input[@name=myname]'): selects all elements matched by input that
have a name value exactly equal to myname
•
•
•
•
•
49. Chapter 2
[ 29 ]
Description
For more information on this attribute selector, see the introduction to Attribute
Selectors above.
Attribute Value Does Not Equal: [@foo!=bar]
All elements that do not have the foo attribute with a value exactly equal to bar.
Examples
1. $('a[@rel!=nofollow]'): selects all elements matched by a that do not
have a rel attribute with a value exactly equal to nofollow
2. $('input[@name!=myname]'): selects all elements matched by input that
do not have a name attribute with a value exactly equal to myname
Description
Since these selectors see attribute values as a single string, $('[a@rel!=nofollow]')
we will select a rel=nofollow self href=example.htmSome text/a.
If we need to select only a elements that do not have nofollow anywhere within
their rel attribute, we can use the following selector expression instead:
$('a:not([@rel*=nofollow])').
Attribute Value Begins: [@foo^=bar]
All elements that have the foo attribute with a value beginning exactly with the
string bar.
Examples
1. $('a[@rel^=no]'): selects all elements matched by a that have a rel
attribute value beginning with no
2. $('input[@name^=my]'): selects all elements matched by input that have
a name value beginning with my
Description
Since these selectors see attribute values as a single string, $('[a@rel^=no]') will
select a rel=nofollow self href=example.htmSome text/a but not
a rel=self nofollow href=example.htmSome text/a.
50. Selector Expressions
[ 30 ]
Attribute Value Ends: [@foo$=bar]
All elements that have the foo attribute with a value ending exactly with the
string bar.
Examples
1. $('a[@href$=index.htm]'): selects all elements matched by a that have
an href value ending with index.htm
2. $('a[@rel$=self]'): selects all elements matched by p that have a class
value ending with bar
Description
Since these selectors see attribute values as a single string, $('[a@rel$=self]')
will select a rel=nofollow self href=example.htmSome text/a but not
a rel=self nofollow href=example.htmSome text/a.
Attribute Value Contains: [@foo*=bar]
All elements that have the foo attribute with a value containing the substring bar.
Examples
1. $('p[@class*=bar]'): selects all elements matched by p that have a
class value containing bar
2. $('a[@href*=example.com]'): selects all elements matched by a that
have an href value containing example.com
Description
This is the most generous selector of the jQuery attribute selectors that match
against a value. It will select an element if the selector's string appears anywhere
within the element's attribute value. Therefore, $('p[@class*=my]') will
select p class=yourclass myclassSome text/p, p class=myclass
yourclassSome text/p, and p class=thisismyclassSome text/p.
Form Selectors
The following selectors can be used to access form elements in a variety of states.
When using any of the form selectors other than :input, providing a tag name as
well is recommended (for example, input:text, rather than :text).
All form elements (input (all types), select, textarea, button)
All text fields (input type=text)
•
•
51. Chapter 2
[ 31 ]
All password fields (input type=password)
All radio fields (input type=radio)
All checkbox fields (input type=checkbox)
All submit inputs and button elements (input type=submit, button)
All image inputs (input type=image)
All reset buttons (input type=reset)
All button elements and input elements with a type of button (button,
input type=button)
All user interface elements that are enabled
All user interface elements that are disabled
All user interface element—checkboxes and radio buttons—that are checked
All elements, including input type=hidden /, that are hidden
For more information, see the discussion on :hidden in the Custom Selectors
section below.
Custom Selectors
The following selectors were added to the jQuery library as an attempt to address
common DOM traversal needs not met by either CSS or basic XPath.
Even Element (:even) Odd Element (:odd)
All elements with an even index:
:even
All elements with an odd index:
:odd
Examples
1. $('li:even'): selects all elements matched by li that have an even
index value
2. $('tr:odd'): selects all elements matched by tr that have an odd
index value
•
•
•
•
•
•
•
•
•
•
•
52. Selector Expressions
[ 32 ]
Description
Because the custom :even and :odd pseudo-classes match elements based on their
index, they use JavaScript's native zero-based numbering.
Somewhat counter-intuitively, therefore, :even selects the first, third, fifth (and so
on) elements while :odd selects the second, fourth, sixth (and so on) elements.
The one exception to this rule is the :nth-child(n) selector, which is one-based. So,
:nth-child(even) selects the second, fourth, sixth (and so on) child element of its
parent. Also worth noting is the lack of a colon preceding even or odd when used
with :nth-child().
Nth Element (����������������
:eq(n), :nth(n)�
)
The element with index value equal to n.
Examples
1. $('li:eq(2)'): selects the third li element
2. $('p:nth(1)'): selects the second p element
Description
Because the JavaScript index is zero-based, :eq(0) and :nth(0) select the first
matched element, :eq(1) and :nth(1) select the second, and so on.
Greater Than :gt(n)
All elements with index greater than N.
Examples
1. $('li:gt(1)'): selects all elements matched by li after the second one
2. $('a:gt(2)'): selects all elements matched by a after the third one
Description
Because the JavaScript index is zero-based, :gt(1) selects all matched elements
beginning with the third one, :gt(2) selects all matched elements beginning with
the fourth, and so on. Consider the following HTML:
ul
li id=firstindex 0/li
li id=secondindex 1/li
li id=thirdindex 2/li
li id=fourthindex 3/li
/ul
53. Chapter 2
[ 33 ]
$('li:gt(1)') selects li id=third and li id=fourth, because their
indexes are greater than 1.
$(li:gt(2)') selects li id=fourth, because its index is greater than 2.
Less Than : lt(n)
All elements with index less than N.
Examples
1. $('li:lt(2)'): selects all elements matched by li element before the
third one; in other words, the first two li elements
2. $('p:lt(3)'): selects all elements matched by p elements before the
fourth one; in other words the first three p elements
Description
Because the JavaScript index is zero-based, :lt(2) selects the first two matched
elements, or all matched element before the third one; :lt(3) selects the first three
matched elements, or all matched elements before the fourth; and so on.
First :first
The first instance of an element.
Examples
1. $('li:first'): selects the first li element
2. $('a:first'): selects the first a element
Discussion
The :first pseudo-class is shorthand for :eq(0). It could also be written as :lt(1).
Last :last
The last instance of an element.
Examples
1. $('li:last): selects the last li element
2. $('#container .myclass:last): selects the last element that has a class
of myclass and is a descendant of the element with an id of container
54. Selector Expressions
[ 34 ]
Description
While :first has equivalent selectors (nth(0) and eq(0)) the :last
pseudo-class is unique in its ability to select only the last element in the set of
matched elements.
Parent :parent
All elements that are the parent of another element, including text.
Examples
1. $(':parent'): selects all elements that are the parent of another element,
including text
2. $(td:parent'): selects all elements matched by td that are the parent of
another element, including text
Description
The W3C recommends that the p element have at least one child node, even if
that child is merely text (see http://www.w3.org/TR/html401/struct/text.
html#edef P). For example, some elements, on the other hand, are empty (i.e. have
no children) by definition: input, img, br, and hr.
One important thing to note with :parent (and :empty) is that child elements
include text nodes.
Contains :contains(text)
All elements that contain the specified text.
Examples
1. $('p:contains(nothing special)'): selects all elements matched by p
that contain the text nothing special
2. $('li:contains(second)'): selects all elements matched by li that
contain the text second
Description
The matching text can appear in the selector element or in any of that element's
descendants. Therefore, example 1 would still select the following paragraph:
pThis paragraph is spannothing strongspecial/strong
/span/p
56. At no post, I am fain to confess, have I seen a larger number of
mementos of Indian hostility than at this fort. And the negroes had
all the more cause to dread attacks from the Indians, as they had
been accosted the first time they went out—a fatigue-party, to cut
wood—by an Indian chief, who told them that he was their brother,
and that it was their duty to come and join his band against their
common enemy, the white man. The black braves refused, returning
to the post without their load of wood; and since that time no
fatigue-party ever returned that did not bring back at least one of
their number dead or wounded.
The last thing we did before leaving this post was to stop at the
large basin of water, Cook's Spring, there to drink, and let the
animals drink, a last draught of the pure, clear flood. How many a
heart had this spring gladdened, when its sight broke on the longing
eyes of the emigrant, before human habitations were ever to be
found here! Just at the foot of the rough, endless mountain, the
men who had come under protection of our train from Fort
Cummings pointed out where the two mail-riders coming from Camp
Bayard—our destination—had been ambushed and killed by the
Indians only the week before. I had heard of these two men while at
the Fort, one of whom, a young man hardly twenty, seemed to have
an unusually large number of friends among men of all classes and
grades. When smoking his farewell pipe before mounting his mule
for the trip to Camp Bayard, he said: Boys, this is my last trip.
Mother writes that she is getting old and feeble; she wants me to
come home; so I've thrown up my contract with Uncle Sam, and I'm
going back to Booneville just as straight as God will let me, when I
get back from Bayard. It's hard work and small pay, anyhow—sixty
dollars a month, and your scalp at the mercy of the red devils every
time you come out. The letter was found in the boy's pocket when
the mutilated body was brought in.
It was no idle fancy when I thought I could see the ground torn up
in one place as from the sudden striking out of horses' hoofs. One of
the men confirmed the idea that it was not far from the place where
57. the body had been found. The mule had probably taken the first
fright just there, where the rider had evidently received the first
arrow, aimed with such deadly skill that he fell in less than two
minutes after it struck him.
This gloomy spot passed, the country opened far and wide before
us; level and rather monotonous, but with nothing of the parched,
sterile appearance that makes New Mexico so dreaded by most
people. Trees were few and far between; but later, where the
Mimbres river rolls its placid waters by, there are willows, and ash
even, as I have heard people affirm. But I must not forget the hot
spring we camped by for an hour or two, the Aqua Caliente of the
Mexicans. A square pond, to approach which you must clamber up a
natural mud wall some two feet high, lay bubbling and steaming
near the shade of some half dozen wide-spreading trees. That
corner of the pond where the water boils out of the earth had once
been tapped, apparently, and the water led to the primitive bath-
tubs, made by digging down into the hard, clayey ground. A
dismantled building showed that the place had at some time been
permanently occupied, which was said to be the case by the Mexican
family living under one of the trees, and who were sojourning here
for the purpose of having life restored to the paralyzed limbs of one
of the children. The people who had lived here were driven off by
Indians, but I have heard since that the place had been rebuilt.
The second day after leaving Fort Cummings we came in sight of a
lovely valley, enclosed on all sides by low wooded hills, with bold,
picturesque mountains rising to the sky beyond. A clear brook—so
clear that it was rightly baptized Minne-ha-ha—gambolled and
leaped and flashed among the green trees and the white tents they
overhung; and in their midst a flag-staff, at whose head the stars
and stripes were flying, told me that we had reached our journey's
end.
58. TO TEXAS, AND BY THE WAY.
I had not seen New Orleans since I was eight years of age, and to
Texas I had never been; so I was well pleased with the prospect of
visiting the southern country. To one coming direct from California,
overland by rail, it seems like entering a different world—a world
that has been lying asleep for half a century—when the great pan-
handle route is left to one side, and Louisville once passed. Though
we know that the country was not asleep—only held in fetters by the
hideous nightmare, Civil War—I doubt if the general condition of
things would have been in a more advanced state of prosperity if the
old order of affairs had remained unchanged, as the march of
improvement seems naturally to lag in these languid, dreamy-looking
southern lands.
The line between the North and the South seems very sharply drawn
in more respects than one. We were scarcely well out of Louisville
before delays and stoppages commenced; and though the country
was pleasant enough to look at in the bright, fall days, it was not
necessary to stop from noon till nightfall in one place, to fully enjoy
the pleasure. Another drawback to this pleasure was the reliance we
had placed on the statement of the railroad agent, who told us it
was quite unnecessary to carry a lunch-basket on this route. Since
we had found a lunch-basket, if not really cumbersome, at least not
at all indispensable, from Sacramento to Omaha, we saw no reason
why we should drag it with us through a civilized country, and
consequently suffered the penalty of believing what a railroad ticket-
agent said. In another section of the same sleeping-car with us was
a party who had been wiser than we, and had brought loads of
provisions with them. No wonder: they were Southerners, and had
learned not to depend on the infallibility of their peculiar institutions.
59. The head of the party was a little lady of twenty-five or thirty years,
with pale, colorless face, and perfectly bloodless lips. I should have
gone into all sorts of wild speculations about her—should have
fancied how a sudden, dread fright had chased all the rosy tints from
her lips back to her heart, during some terrible incident of the war;
or how the news, too rashly told, of some near, dear friend stricken
down by the fatal bullet, had curdled the red blood in her veins, and
turned it to ice before it reached her cheeks—had she not been so
vigorous and incessant a scold. Now it was the French waiting-maid
to whom she administered a long, bitter string of cutting rebukes,
while the unfortunate girl was lacing up my lady's boots; next it was
her younger sister—whom she was evidently bringing home from
school—whose lips she made to quiver with her sharp words; and
then, for a change, the mulatto servant was summoned, by the well-
scolded waiting-maid, to receive his portion of the sweets meted
out. An ugly thing she was, and so different from the Southern lady I
had met in the hotel at Louisville—one of the most beautiful women
I have ever seen—whose grace nothing could exceed as she handed
me a basket of fruit across the table, when one glance had told her
that I was a stranger and tired out with the heat and travel.
But, in spite of what I have said, I must confess that I accepted the
sandwiches the little scold sent us, for the supper-station was not
reached till eleven o'clock at night. As the conductor promised us
another good, long rest here, the gentlemen left the ladies in the
cars, and returned after some time, followed by a number of
negroes, who carried a variety of provisions and divers cups of
coffee. I thought, of course, that it was luncheon brought from some
house established at the station for that purpose; but was told that
the chicken the mulatto boy was spreading before us had been
abstracted from his massa's hen-yard, and that the eggs the old
negro was selling us had not by any means grown in his garden.
Only the coffee, which was sold at twenty-five cents a cup, was a
legitimate speculation on the part of some white man (I am sure his
forefathers were from the State of Maine), who went shares with the
negro peddling it, and charged him a dollar for every cup that was
60. broken or carried off on the cars, which accounted for the sable
Argus' reluctance to leave our party till we had all swallowed the
black decoction and returned the cups.
We were to take dinner at Holly Springs, some time next day; and it
was some time before we got there, sure enough. We had picked
up an early breakfast somewhere on the road, and when the dinner-
bell rang at the hotel as the cars stopped, we did not lose much time
in making our way to the dining-room. The door, however, was
locked, and we stood before it like a drove of sheep, some hundred
or two people. Through the window we could see mine host, in shirt-
sleeves and with dirty, matted beard, leisurely surveying the crowd
outside; in the yard, and on the porch near us, stood some
barefooted negroes, with dish-cloth and napkin in hand, staring with
all their might at train and passengers, as though they were lost in
speechless wonder that they should really have come. In the party
with us was a Californian, some six feet high, who, though a
Southerner by birth, had lived too long in California to submit
patiently to the delay and inconvenience caused by the
shiftlessness of the people hereabouts.
Now, you lazy lopers, he called to the darkies, swinging the huge
white-oak stick he carried for a cane, get inside to your work. And if
that door ain't opened in five seconds from now, I'll break it down
with my stick.
He drew his watch; and, either because of his determined voice, or
his towering figure, the darkies flew into the kitchen, and the
landlord sprang to open the door, while the crowd gave a hearty
cheer for the big Californian.
New Orleans seemed familiar to me; I thought I could remember
whole streets there that I had passed through, as a little child,
clinging to the hand of my father—himself an emigrant, and looking
on all the strange things around him with as much wonder as the
two little girls he was leading through the town. How it came back to
me! the slave-market, and the bright-faced mulatto girl, hardly
61. bigger than myself, who so begged of my father to buy her and take
her home with him, so that she could play with and wait on us.
There was nothing shocking to me, I regret to say, in seeing this
laughing, chattering lot of black humanity exposed for sale, though
my good father doubtlessly turned away with a groan, when he
reflected on what he had left behind him, in the old fatherland, to
come to a country where there were liberty and equal rights for all. I
can fancy now what he must have felt when he spoke to the little
woolly-head, in his sharp, accentuated dialect, which his admirers
called perfect English, as he passed his hand over her cheek and
looked into her face with his great, kind eyes. He said he had
brought his children to a free country, where they could learn to
work for themselves, and carve out their own fortunes; and where
they must learn to govern themselves, and not govern others.
Day after day, on foot or in carriage, we rambled through the
streets, and I never addressed a single question to the driver or any
of the party, satisfied with what information accidentally fell on my
half-closed ear. I was living over again one of the dreams of my early
days: the dream I had dreamed over again so often, among the
snows of the biting, cold Missouri winter, and on the hot, dusty
plains of Arizona, amid the curses of those famishing with thirst and
the groans of the strong men dying from the fierce stroke of the
unrelenting sun. Passing through the parks and by the marketplaces,
I saw again the negro women, with yellow turbans and white
aprons, offering for sale all the tempting tropical fruits which
foreigners so crave, and still dread. And I thought I saw again the
white, untutored hands of my father, as he laboriously prepared
seats for us in the deepest shade of the park, and dealt out to us the
coveted orange and banana. The cool, delicious fruit, and the picture
of flowers and trees in the park; the black, kindly faces of the negro
servants, and the laughing, white-clad children at play—how often I
had seen them again in my dreams on the desert!
Canal street looked lonely and deserted, as did the stores and shops
lining either side of the broad, aristocratic street. The material for a
62. gay, fashionable promenade was all there; only the people were
wanting to make it such. True, there were groups occasionally to be
seen at the counters of the shops, but in most such cases a black,
shining face protruded from under the jaunty little bonnet, perched
on a mass of wool, augmented and enlarged by additional sheep's-
wool, dyed black. One of these groups dispersed suddenly one day,
vacating the store with all the signs of the highest, strongest
indignation. The tactless storekeeper, who had not yet quite
comprehended the importance and standing of these useful
members of society, had unwittingly offended an ancient, black
dame. She had asked to see some silks, and the shopkeeper had
very innocently remarked, Here, aunty, is something very nice for
you.
I wish to deform you, sir, replied Aunt Ebony, bridling, that my
name is Miss Johnson. With this she seized her parasol and
marched out of the store, followed by her whole retinue, rustling
their silks, in highest dudgeon.
On my way to the ferry, when leaving New Orleans for Texas, I saw
something that roused all the Southern feeling in me. Two colored
policemen were bullying a white drayman, near the Custom-house. I
must confess I wanted to jump out, shake them well, take their
clubs from them, and throw them into the Mississippi (the clubs, I
mean, not the precious niggers). What my father would have said,
could he have seen it, I don't know; the grass had long grown over
his grave, and covered with pitying mantle the scars that
disappointments and a hopeless struggle to accomplish purposes,
aimed all too high, leave on every heart.
As the cars carried us away from the city, and gave us glimpses of
the calm water, and the villas, and orange-groves beyond, there
came to me, once more,
The tender grace of a day that is dead.
63. It was just a soft, balmy day as this, years ago, when we lay all day
long in a bayou, where the water was smooth and clear as a mirror,
and the rich grass came down to the water's edge; and through the
grove of orange and magnolia, the golden sunlight sifted down on
the white walls and slender pillars of the planter's cottage. Stalwart
negroes sang their plaintive melodies as they leisurely pursued their
occupation, and birds, brighter in plumage than our cold, German
fatherland could ever show us, were hovering around the field and
fluttering among the growing cotton.
The graceful villa was still there, and the glassy waters still as death;
but the villa was deserted, and the rose running wild over magnolia-
tree and garden-path; the cotton-field lay waste, and the negro's
cabin was empty, while the shrill cry of the gay-feathered birds alone
broke the silence that had hopelessly settled on the plantation.
Farther on, I saw the cypress-forests and the swamps, and I fancied
that the trees had donned their gray-green shrouds of moss because
of the deep mourning that had come over the land. The numberless
little bayous we crossed were black as night, as though the towering
trees and the tangled greenwood, under which they crawled along,
had filled them with their bitter tears. But the sun shone so brightly
overhead, that I shook off my dark fancies, particularly when my
eyes fell on the plump, white neck and rounded cheeks of the lady in
the seat before me. I had noticed her at the hotel in New Orleans,
where I recognized her at once as a bride, though she had
abstained, with singularly good taste, from wearing any of the
articles of dress outwardly marking the character. I hoped, secretly,
that I might become acquainted with her before the journey ended,
for there was something irresistibly charming to me in her pleasant
face and unaffected manner. My wish was soon gratified; for the
very first alligator that came lazily swimming along in the next bayou
so filled her with wonder, that she quickly turned in her seat and
called my attention to it. Soon came another alligator, and another;
and some distance below was a string of huge turtles, ranged,
according to size, on an old log. As something gave way about the
engine at this time, we could make comments on the turtle family at
64. our leisure; and when the cars moved on again, we felt as though
we had known each other for the last ten years.
I cannot think of a day's travel I have ever enjoyed better than the
ride from New Orleans to Brashear. The dry, dusty roads and
withered vegetation I had left behind me in California, made the
trees and green undergrowth look so much more pleasant to me.
The ugly swamp was hidden by the bright, often poisonous, flowers
it produces; and though the dilapidated houses and ragged people
we saw were not a cheerful relief to the landscape, it was not so
gloomy as it would have been under a lowering sky or on a barren
plain.
A steamer of the Morgan line, comfortable and pleasant as ever a
steamer can be, carried us to Galveston—a place I had pictured to
myself as much larger and grander. But the hotel—though my room
did happen to look out on the county jail—was well kept; and some
of the streets looked like gardens, from the oleander-trees lining
them on either side. The trees were in full blossom, and they gave a
very pleasant appearance to the houses, in front of which they
stood. Some few of these houses looked like a piece of fairyland:
nothing could have been built in better taste, nothing could be kept
in more perfect order. Too many of them, however, showed the signs
of decay and ruin, that speak to us with the mute pathos of
nerveless despair from almost every object in the South. We planned
a ride on the beach for the next day, which we all enjoyed, in spite
of the somewhat fresh breeze that sprung up. The bride was anxious
to gather up and carry home a lot of relics—a wish the bridegroom
endeavored to gratify by hunting up on the strand a dead crab, a
piece of ship-timber, and the wreck of a fisherman's net. Discovering
that the driver was a German, I held converse with him in his native
tongue, which had the pleasing effect of his bringing to light, from
under the sand, a lot of pretty shells, which the delighted little bride
carried home with her.
The following day we started for Houston. Eight o'clock had been
mentioned as the starting hour of the train for that locality, but the
65. landlord seemed to think we were hurrying unnecessarily when we
entered the carriage at half-past seven. There was no waiting-room
at the starting-point that I could see, and we entered the cars,
which stood in a very quiet part of the town (not that there was the
least noise or bustle in any part of it), and seemed to serve as sitting
and dining-rooms for passengers, who seemed to act generally as if
they expected to stay there for the day. But we left Galveston
somewhere toward noon, and since we were all good-natured
people, and had become pretty well accustomed to the speed of the
Southern railroads, we really, in a measure, enjoyed the trip. The
people in the cars—many of the women with calico sun-bonnets on
their heads, and the men in coarse butternut cloth—reminded me of
the Texan emigrants one meets with in New Mexico and Arizona,
where they drag their weary length along through the sandy plains
with the same stolid patience the passengers exhibited here,
listlessly counting the heads of cattle that our train picked up at the
different stations on the road. The wide, green plains looked
pleasant enough, but I wanted to stop at the little badly-built
houses, and earnestly advise the inhabitants to plant trees on their
homesteads, as the best means of imparting to them the air of
home, which they were all so sadly lacking. The cattle roaming
through the country looked gaunt and comfortless—like the people
and their habitations.
Night crept on apace; and though I have forgotten (if I ever knew)
what the cause of delay happened to be, I know that we did not
reach Houston till some five or six hours later than the train was
due. I was agreeably surprised to find vehicles at the depot, waiting
to carry passengers to the different hotels. Our hotel-carriage was
an old omnibus, with every pane of glass broken out; and the
opposition hotel was represented by a calash, with the top torn off
and the dashboard left out. Still more agreeable was the surprise I
met with in the hotel itself—a large, handsome, well-furnished
house, giving evidence in every department of what it had been in
former days. Before the war, the step of the legislator had
resounded in the lofty corridor, and the planter and statesman had
66. met in the wide halls, bringing with them life, and wealth, and social
enjoyment to the proud little city. Now, alas! the corridors were
cheerless in their desolation, and the grand parlors looked down
coldly on the few people gathered there. The proprietor had years
ago lived in California; and of this he seemed unreasonably proud,
as something that everybody could not accomplish. His wife was a
Southern woman, and had not yet learned to look with equanimity
upon the undeniable fact that her husband was keeping a hotel. I
am sure that she had no reason to deplore the loss of her husband's
wealth and slaves on that account; for both she and her husband
were people who would have been respected in any part of the
world, even if they had not kept hotel.
In the midst of a hot, sultry day, a fierce norther sprang up, chilling
us to the bone, and causing us to change our original intention of
remaining here for some time. The bride, too, and her husband,
were willing to return to a more civilized country at an early day.
Together we went back, and were greeted at the hotel we had
stopped in, and by people on the steamer, as pleasantly as though
we were in the habit of passing that way at least once a month. At
New Orleans we parted, the new husband and wife returning to St.
Louis, while I retraced my steps to Louisville, en route to New York.
In the cars I was soon attracted by the appearance of a lady and
gentleman—evidently brother and sister—accompanied by an elderly
negro woman. The gentleman seemed in great distress of mind, and
the lady was trying to speak comfort to his troubled spirits. The
negro woman would gaze longingly out of the window, shading her
eyes with her hand, and then stealthily draw her apron over her
cheeks, as though the heat annoyed her. But I knew she was crying,
and the sobs she tried to repress would sometimes almost choke the
honest old negro. The train went so slow—so slow; and the
gentleman paced nervously up and down, whenever the cars
stopped on the way.
Great sorrow, like great joy, always seeks for sympathy; and in a
short time I knew the agony of the father, who was counting every
67. second that must pass before he could reach the bedside of his
dying child. A young, strong maiden, she had been sent by the
widowed father to a convent, in the neighborhood of Louisville, there
to receive the excellent training of the sisters of the school. Stricken
down suddenly with some disease, they had immediately informed
the father by telegraph; and he, with his sister, and Phrony, the old
nurse of the girl, had taken the next train that left New Orleans.
Both he and his father had been prominent secessionists, had been
wellnigh ruined by the war, and had hoarded what little they could
save from the common wreck, only for this daughter—and now she
was dying. So slowly moved the train! Hour after hour the brother
paced up and down the narrow space in the cars, while the sister
poured into my ears the tale of his hopes and fears, their
wretchedness and their perseverance during the war, and how, in all
they had done and left undone, the best interests of Eugenia had
been consulted and considered. The negro woman had crouched
down at our feet, and was swaying back and forth with the slow
motion of the cars, giving vent to her long pent up grief, and
sobbing in bitterness of heart: Oh, Miss Anne! Miss Anne! why
didn't you let me go with my chile?
To make full the cup of misery, we were informed next morning that
our train would stop just where it was till six o'clock in the evening,
when some other train would come along and carry us on. I don't
think that the colonel (the father) did any swearing, but I fear that
some of the Californians who were of our party did more than their
share. Going to the nearest station, he telegraphed the cause of his
delay to the sisters of the convent, and then waited through the
intolerably long day. At nightfall the train moved on, slowly, slowly,
creeping into Louisville at last, in the dull, cold, dismal day. Snow-
flakes were falling in the gray atmosphere, settling for a moment on
the ragged, shivering trees, ere they fluttered, half dissolved, to the
muddy ground. The wind rose in angry gusts now and again,
whirling about the flakes, and trying to rend the murky clouds
asunder, as though jealous of the drizzling fog that attempted to
take possession of the earth.
68. Breathlessly the colonel inquired for dispatches at the hotel. Yes; his
child still lived! A buggy was ready, awaiting them at the door, and
the brother and sister drove off, leaving Phrony to take possession of
their rooms. I can never forget the heart-broken look of Phrony
when the buggy vanished from sight.
You see, said I, there was no room in the buggy for you. If they
had waited to engage a carriage, they might have been too late.
Yes, Miss, said Phrony, absently, and turned away.
Toward the close of the day, when already hooded and cloaked for
the onward journey, I was informed that Eugenia was dead: her
father had received but her parting breath. The dispatch was sent
for the information of those who had shown such sympathy for the
grief-stricken father. I stepped over to the colonel's rooms, where I
knew Phrony was. She was sitting on a little trunk by the fire, with
her apron over her head, and her body bent forward.
Then you know it, Phrony? I asked.
Yes, yes; knowed it all along, Miss. Hadn't never no one to take
care of her but her old mammy! Oh, my chile! my chile! my little
chile! And she's done gone died, without her mammy! Oh, my chile!
my chile!
I tried to speak kindly to her, but my sobs choked me. I looked out
of the window, but there was no light there. The snow was falling to
the ground in dogged, sullen silence, and the wind, as though tired
out with long, useless resistance, only moaned fitfully at times, when
clamoring vainly for admission at the closed windows.
Was it not well with the soul just gone to rest? Was it not better with
her than with us—with me—who must still wander forth again, out
into the snow, and the cold, and the night?
Oh, my chile! my chile! sobbed the woman, so black of face, but
true of heart; if I could only have died, and gone to heaven, and
69. left you with Massa Harry! Oh, Miss Anne! Miss Anne! what made
you take my chile away from me?
It is only for a little while that you will be parted from her, Phrony,
I said.
Bress de Lord! Yes, I'll soon be with my little chile again. But she's
dead now, and I can't never see her no more. Oh, my chile! my
chile!
I closed the door softly, for I heard the warning cry of the coachman
who was to take us to the outgoing train.
70. MY FIRST EXPERIENCE IN NEW
MEXICO.
On a warm, pleasant afternoon in the latter part of August, 1866,
our command reached the post to which it had been assigned—Fort
Bayard, New Mexico. Our ambulance was driven to the top of a little
hill, where I had leisure to admire the singular beauty of the
surrounding country, while my husband was superintending the
pitching of the tent.
The command to which we belonged was the first body of Regulars
that had been sent across the Plains since the close of the war. Fort
Bayard had been garrisoned by a company of colored troops, who
were now under marching orders, and our soldiers were to build the
fort, which, as yet, existed only in the general's active brain. The
Pinos Altos gold mines were only twelve miles distant from here, and
all the other mines—copper and gold—lying within a range of fifteen
miles, had been prosperously and profitably worked, by Mexicans
and Americans; but after the breaking out of the war, when the
troops had been withdrawn from the Territory, bands of roving,
hostile Indians had visited one mine after another, leaving in their
wake mutilated corpses and blackened ruins. The news of the
soldiery coming to this rich mining country was drawing miners and
adventurers from far and near, and Pinos Altos promised to become
a mining district once more.
Looking around me, I saw a number of officers approaching from
where the One Hundred and Twenty-fifth Infantry was camped. They
came to welcome us to the camp, and I should have liked to receive
them in style; but all I could do was to smooth my hair with my
hand. The tent was not yet pitched, and I certainly should not leave
the ambulance, for I had observed hosts of centipedes crawling out
71. from under the rocks that had been removed to make room for the
tent-poles. The officers grouped themselves around the ambulance,
and after congratulating us on our safe arrival, wondered how I had
ever found courage to come to this place. Did it not seem an age
since I had parted with the last lady, at Fort Selden? and How
would I like living here—the only lady in this wilderness—without
quarters, without comforts of any kind?
Oh, I shall do nicely, I said. I have not slept under a roof since
leaving Fort Leavenworth, five months ago, and all the comforts we
are in want of are commissaries; which of you, gentlemen, is
quarter-master, by the way? I should like to send to the commissary
to-day, though it is after issuing hours.
Yes, certainly, said the quarter-master; but our supply is limited
just now. What do you wish for?
Sugar, coffee, tea, I enumerated; canned fruit, rice—
Stop! stop! hurriedly exclaimed the quarter-master; all in the
world we have in the commissary is soap, salt, and beans. We have
taken our coffee without sugar since the Apaches captured the last
train, and we rather hoped to get commissaries from your train.
Accustomed as I had become to live on hard tack and bacon
occasionally, when it was dangerous to light fires, on account of
drawing the Indians, this piece of information did not dampen my
spirits in the least; but at night, while the cook was preparing our
supper of coffee, bacon, and soda-biscuits, the orderly sergeant of
the company made his appearance at the entrance of our tent, and,
after the usual military salute, presented a large tin-pan filled with
sugar, and a bag with coffee. The men, he said, had requested
that their rations of coffee and sugar be delivered to the lieutenant's
wife, till the next train should bring fresh supplies. The men had
styled me the mother of the company; and this was only one of
the many proofs of good-will and devotion I was constantly
receiving, in return for some little trifling kindnesses I had shown
72. one or the other, while crossing the plains and deserts of Kansas and
New Mexico. A little piece of linen, to tie up a bruised finger; a cup
of vinegar, a lump of white sugar, to change the taste of the
wretched drinking-water, to some poor invalid, were held in sacred
remembrance by these men; and some of them had risked their
lives, in turn, to procure for me a drink of fresh water, when sick and
faint, crossing Jornada del Muerto, that terrible Journey of Death.
Our tent looked cozy enough, when finished and furnished. A piece
of brilliant red carpeting was spread on the ground; the bedding was
laid on planks, resting on trestles; the coverlet was a red blanket;
the camp-chairs were covered with bright cloth, and the supper—
served on the lid of the mess-chest—looked clean and inviting. The
kitchen, just back of the tent, was rather a primitive institution: a
hole dug into the ground, two feet long, a foot wide, with two flat,
iron bars laid over it, was all there was to be seen. Two or three
mess-pans, a spider, and a Dutch-oven constituted our kitchen
furniture; and with these limited means, an old soldier will
accomplish wonders in the way of cooking. Before enlisting, one of
our servants had been a baker; the other, a waiter at a hotel; and,
between them, they managed the task of waiting on us very
creditably. To be sure, my husband's rank entitled him to but one
servant from the company; but then I was the only lady with the
command, and our company commander was considerate of my
comfort.
Reveille always comes early; but that first morning in Fort Bayard it
came very early. The knowledge that we had reached our haven of
rest, after a five months' journey, made me want to sleep. I wished
to feel sure that our tent was not to be struck directly after breakfast
—that the bed would not be rolled up and tumbled into the army-
wagon—that I should not have to creep into the ambulance, and
ride, ride, ride, all that day again. But we had agreed to visit the
great Santa Rita copper mines that day, in company with all the
officers; and Charley was rapping at the tent, to say that breakfast
was almost ready. We started directly after guard-mount: five
73. officers, six men—who had been detailed as escort—and myself. We
were all well mounted. My own horse, Toby—the swiftest and
strongest of them all—was snow-white, with delicate, slender limbs,
and tall, even for a cavalry horse. The camp was located in a valley,
some four miles square; gently rising hills inclosed it on every side;
beyond these, on one side, rose the San José Mountains, and, in an
almost opposite direction, the Pinos Altos Range. All these hills and
mountains were said to contain metal; copper and gold, and even
cinnabar, could be found. And we were now making our way to the
foot-hills, where the officers had promised to show us some rich
leads they had discovered. We dismounted when we had reached
the place; and some of the escort acting as guard against Indian
surprises, the rest were set to work, with picks and hatchets, to
dig up specimens. They had not long to dig, for every rock they
struck contained copper; and frequently the little specks of gold in it
could be seen with the naked eye.
But it must not be supposed that these hills were barren, or
destitute of verdure. On the contrary, as far as the eye could reach,
even the highest mountains were covered with grass, scrub-oaks,
and cedars; while in the valley, and on the hills, there was one bright
carpet of grass and wild flowers. The white tents in the valley, with
the flag-staff in the centre, and the flag just moving in the morning
breeze, the dark-green trees shading the tents, the stream of water
(called by the captain Minne-ha-ha) running around the camp—all
this looked so refreshing, so beautiful, after those long day's
marches among the sand-hills of the Rio Grande, and the weary
tramps over the burning deserts we had lately left behind us, that
my enthusiasm rose to the highest pitch.
Why don't somebody claim this delightful country?—why don't
people in the army resign, and own mines, and settle down here to
live? I asked—very irrationally, I am afraid.
My dear madam, said the captain, leading me to the edge of the
hill, and pointing downward, where, amid the long, waving grass and
bright, laughing flowers, I discovered the charred logs of what had
74. once been a miner's cabin, neither the beauty of the country, nor
the wealth of its minerals, has been overlooked; and hundreds of
men have lost their lives, in trying to wrest from the Indian's grasp
what would be a benefit and blessing to civilization.
I wanted to go near enough to touch with my hand two graves that
were close by the burnt logs, but the captain refused to let me go. It
was about fifty yards from where the guard was placed; and that, he
said, was almost certain death. He promised, that as soon as the
Mexican guide should return from Fort Craig, he would place him,
with a sufficiently large escort, at my command, to visit the whole of
the surrounding country. The guide—old Cecilio—had lived in this
country before it had come into Uncle Sam's possession; had had
many a narrow escape from the Indians, and knew the history of
every mine and shaft in all that region. Pointing to the San José
Mountain Range, the captain said there was a wagon-road leading
along its foot to the Santa Rita mines, but that he knew of an Indian
trail, which would take us there much quicker. Remounting, we
resumed our journey.
New beauty surprised us every little while: sometimes it was a little
silver rivulet, running over the most beautiful ferns; then a group of
trees and red-berried shrubs; and again, a clump of rare flowers. But
one thing weighed down the spirit like lead, in these wild regions: it
was the death-like, uninterrupted silence that reigned over all. There
was nothing of life to be seen or heard—no bird, no butterfly. The
lizard slipped noiselessly over the rocks at your feet, and the
tarantula gaped at you with wide-open eyes, before retreating to the
shelter of her nest in the ground. But even the carrion-crow,
following wherever human beings lead the way, never left the limits
of the camp.
We had now reached a deep ravine. A shallow creek was running at
our feet; dark, frowning mountains seemed to hem us in on every
side; our horses looked tired, and the captain very unexpectedly
announced that he had lost his way! He said he felt sure that this
creek was to be crossed somewhere, but not here where our horses
75. were drinking now. Old Cecilio had always accompanied him before
this, and—and—in short, we were lost! Just then one of the men
rode up to the lieutenant's side, and said something to him in a low
tone. Where? asked he. The man pointed down the creek. The
officers dismounted to examine the ground, and found the fresh
tracks of eight or nine Apache Indians. To be sure, there were
eleven men and officers on our side; but our horses were pretty well
worn, and the camp twenty miles away, for aught we knew. The
men looked to their fire-arms, while the officers consulted. If we
were attacked here, the Indians, even if they could not take us,
could starve us out before any party sent out from the fort could find
us. Therefore, to proceed was our only chance. Perhaps, if we could
succeed in reaching the top of the next mountain, we might discover
some landmark showing us our way back to camp. Some one
proposed to search again for the trail to the copper-mine; but the
captain told us it was one of the favorite haunts of the Indians when
in this part of the country, and this party had probably gone there
now. At last we moved on, the escort so disposed that I was covered
on every side. The mountain was steep, and covered with sharp
rocks, cactus, and chaparral, which appeared to me moving and
peopled with hideous forms. Every moment I expected to hear a
savage yell, and see a shower of arrows flying around our devoted
heads. Many a time a finger was raised and pointed silently, so as
not to frighten me, to some suspicious-looking object; but all
remained quiet, and we reached the summit at last, only to see that
we were surrounded by mountains still higher and steeper than the
one we had climbed. Giving our horses but short breathing-time, we
made the next ascent, hoping then to see our way clear; but again
we were disappointed. Never before, perhaps, had the foot of the
white man left its impress on these solitary heights. There was
untold wealth hidden under these sharp rocks, and in the crevices
and clefts that looked so dark and treacherous in the afternoon sun;
but even the mines of Golconda would have had but little interest for
us just then.
76. We had now come to a mountain that we must descend some five
hundred feet before we could make the ascent of the next. With
trembling legs, the horses began the steep descent; the first horse
stumbled and fell, and then the men were ordered to dismount and
lead their horses. I wanted to do the same, but was told to remain
in the saddle, as I could not mount quick enough, should the Indians
attack us. When the horses found foothold at last, it was almost
impossible to urge them on; so some of the men volunteered to
reconnoitre in different directions, while the officers remained with
me. At last, one of the men, having reached the summit,
telegraphed to us that he had discovered some friendly post, and
made signs how we were to travel round the mountain. Sundown
saw us in camp again, worn out and hungry, but by no means
daunted or discouraged. Santa Rita was to be abandoned until the
old guide returned; but Pinos Altos was to be visited without him, in
a day or two.
Poor Toby was tired and jaded after this exploit, so he was allowed
to roam through camp, at his own sweet will, without lariat or
picket-rope; he could always pick out our tent from the rest, and he
came to look into it, one morning, just as the cook had laid a
freshly-baked loaf of bread on the mess-chest to cool. I had been in
the habit of giving Toby a bite of our lunch whenever the command
halted, and I could reach the lunch-basket; he was satisfied with
anything I gave him—a bit of bacon, a piece of hard-tack, a lump
of sugar—and thinking now, I suppose, that he was being neglected,
when I did not look up from my sewing, he quietly withdrew. The
next moment I heard the men outside shouting, Thief! you thief!
Stepping to the entrance of the tent, I saw Toby, the loaf of bread
firmly between his teeth, making his way, at a two-forty gait, across
the parade-ground. This made our bill of fare rather meagre for that
day—slap-jacks taking the place of the bread. But, then, we would
soon have eggs, the cook said; and he could do so many things with
eggs. Now, these eggs were some that we expected certain
chickens, then en route from Fort Cummings, to lay for us. An officer
there had had some chickens brought up from El Paso, at great
77. expense and greater trouble; of these, he had promised us three
dozen, and they were now coming to Fort Bayard under escort of
ten cavalrymen. I had made Charley promise, on honor, never to ask
to kill one of these for the table, but to content himself with using
the eggs they would, should, and ought to lay. Toward evening the
escort with the wagon came in sight; all the men rushed down the
road to meet it; and when the box containing the chickens was
opened and the flock let loose, the whole company gave three
cheers, and, for days afterward, the men could be heard, all over
camp, crowing like roosters. They never seemed to get tired of
feeding the chickens extra handfuls of corn, religiously bringing to
our kitchen any stray egg a gadding hen had laid in the company
hay.
The morning was cool and bright, when Copp and Toby, capering
and dancing, as though we had never been lost in the mountains,
were led up to the tent. The escort was already mounted, and every
man of the twelve looked upon this as a holiday. They all had their
curiosity to see Pinos Altos; but the clean gauntlets and white shirts
had been donned in honor of this—to them—great event: escorting
the first white lady, an officer's wife, into Pinos Altos. I can never tire
of speaking of the magnificent scenery in this part of New Mexico. It
was not New Mexico—it was a small piece of the Garden of Eden,
thrown in by Providence, from above, in sheer pity for the
Americans, when Uncle Sam made that Ten Million Purchase, known
as the Gadsden. We galloped along a smooth road, made by the
men for hauling fire-wood over, for a mile or two, till we crossed the
Minne-ha-ha, and shortly after struck the Pinos Altos road. It had
been a well travelled road at one time, though the Indian only had
crossed it, in his wanderings, these three or four years past. Scrub-
oak, and shrubs for which I knew no name, by the wayside; the aloe
plant and cactus, grama grass and wild flowers, peeping out from
under fragments of moss-covered rock; here and there a cedar, or
pine, made the impression that we were inspecting extensive
pleasure-grounds; the little stream—Whiskey Creek—that found its
winding way down from Pinos Altos, was bordered by willows, and,
78. though shallow, afforded us all a cool drink. The road rises almost
from the time of leaving the fort, but so gently at first as to be
hardly noticed. Part of the escort rode before us, for those romantic-
looking hills, springing up here and there on our way, had many a
time served as ambush for the savage hordes that infest all this
country; and more than one grave by the road-side spoke of sudden
attack, of sharp contest, and final defeat.
An officer alone would have thought it unnecessary to take so large
an escort as ours, but the commanding officer had stipulated that
the lieutenant must not undertake these rides with me unless he
took twelve men. The Indians would risk any number of their braves,
he said, to get an officer's wife into their possession; and then he
would have to turn out his whole command to rescue me. So, to
save him this trouble, we promised to obey orders.
There was one curious hill, that I never passed without counting
from six to twelve rattlesnakes wriggling up the side of it. This
rattlesnake hill was about half-way between camp and Pinos Altos;
and a mile or two beyond, I saw the first tall pines, from which this
region takes its name. They were giants, in fact; it made me dizzy to
look up to the tallest point I could see, as the tree swayed gently to
and fro against the deep-blue sky.
Our horses were walking now; the hills grew into mountains, and
came closer around us; the road was hardly a road any more—I
doubt that anything but Indian ponies or pack-trains had ever gone
over it, till the boys in blue came here—and the inconsiderate
thorns caught and tore my best riding-habit at every step. We
could now see the red earth the miners in this section liked so well
to find; they had been prospecting all along Whiskey Creek, but had
gone higher and higher, till settling in Pinos Altos proper, at last. Up,
up, we went, till I thought we must be nearing the clouds. The air
felt sharp and cool, even in the midday sun, but we had not yet
reached the summit.
79. At last the advance-guard halted, and one of the men, turning,
uttered an exclamation of wonder and surprise. The Pinos Altos
people had cut down the tall pines as much as possible on this side,
because the Indians had always approached under cover of them
when they had made their attacks on the place; and now, without
hindrance or obstruction, we had a view, such as I have never
enjoyed since. All the mountains I had thought so immensely high
lay at our feet, and away beyond them I could see far into the
country—for hundreds of miles, it seemed to me. To the right of us,
we could peer into Old Mexico; the Three Brothers—three peaks
very similar in appearance and close together—were pointed out to
me; and over that way was Janos, they said—the first town after
crossing the border—the place our deserters and fugitives from
justice always tried to reach. Five minutes' ride now brought us in
sight of Pinos Altos—a few straggling shanties, built of logs, brush,
or adobe, just as it happened to suit the builder. Beyond Pinos Altos
the world seemed literally shut in, or shut out, by mountains; there
was snow on the highest peaks nine months of the year; no one had
felt inclined to explore them as yet—indeed, it was all people could
do to draw their breath comfortably here, I thought. The streets in
this city had not yet been thoroughly regulated, as some of the
inhabitants had found it convenient to commence mining operations
in, or immediately outside, their houses; and, following a good lead
they had struck, had sometimes continued these operations till some
other miner, with six-shooter in hand, had declared no man had a
right to dig round his shanty. Some other miner had coaxed the
waters of Whiskey Creek on to his claim, situated on the other side
of town, having dug for this purpose a ditch some five or six feet
deep. Still another had sunk a shaft twenty feet deep, at his front
door, so as to hold that mine for two years. But mining was not
confined to the streets of the city, by any means; companies of five,
six, or twenty men had ventured out as far as their number would
permit. It would not have been a very safe occupation at the best;
for even our men, when sent to cut hay within sight of the fort, had
to work with their revolvers buckled on, and their carbines within
reach. How much more, then, did these men risk, in lonely, out-of-
80. the-way places, where no succor could reach them—where only the
serene sky overhead, and the red demon inflicting the torture, could
hear the last agonized cry that escaped the blanched lips of his
writhing, helpless victim.
As we approached, the miners laid down their picks, and stared at
us. Here and there a Mexican woman, who had followed the
fortunes of her lord and master into the wilderness, appeared at the
door of some shanty, her head covered with the inevitable rebozo;
and, taking a quick survey of our party, would vanish the next
moment to communicate the news of our arrival to her amigos and
compadres. Taking the ditches, but carefully avoiding the shafts,
we came to a house rather larger and better-appearing than the
rest, and were invited by a mannerly Spaniard to alight and rest in
his house. His wife waited on us in the pleasantest manner; but
the building we had entered consisted of only one room, which was
store, sitting-room, kitchen, and all. The news of our arrival spread
like wild-fire; miners from far and near hurried to Rodriguez' store;
and the place being small, the circle around us was soon as close as
good manners would allow of—and good manners they all had,
Mexicans and Americans. Those who could not find room inside,
were out by the door, patting Toby, examining my side-saddle, and
asking questions of the escort. Señor Rodriguez was in the habit of
weighing the gold the miners found in the course of the day, and
buying it for greenbacks, or exchanging for it such provisions as he
had on hand. A huge, bearded Mexican stepped up to the little
counter now, and emptying his leather bag of its shining contents,
selected the largest piece—the size of a hazel-nut—and presented it
to me, with an air of such genuine honesty, such chivalric grace, that
I felt I could not refuse the gift without wounding the man's feelings.
I could only say, Thank you, in English; but having accepted this
first offering, I could not refuse to accept from the rest the largest
piece of gold each miner had found that day. The first piece had
been the largest found.
81. Taking our departure when the sun was almost hidden behind the
mountains, we could not shake off a nervous feeling as we picked
our way through the labyrinth of rocks, trees, and shrubs, for this
was the favorite hour for Indian attacks. They hardly ever attack a
train or camp after night; their chosen time is just before dark, or
early in the morning, before sunrise; of course, they are not
particular as to what hour of the day they can appropriate your
scalp, but they have seldom or never been known to attack the
whites at night.
We could already see the camp-fires in the distance, when a number
of stealthily moving objects in the road attracted my attention. Toby
snorted as though an Indian were already clutching at the bridle; but
a most discordant yelping, barking, and howling struck my ear just
then like the sweetest of music: a pack of coyotes only had gathered
around us. They followed us all the way to camp, and, surrounding
our quarters, kept up their serenade till broad daylight. A band of
equally musical wild-cats had chosen the infantry camp as the
theatre for their performances; and an occasional roar from one of
those long-built, panther-like animals called California lions taught
me that there was life and animation in Nature here at night, if not
in the daytime.
Old Cecilio having returned during our absence, we started out, the
next morning, after guard-mount, on another exploring expedition.
When the hills, shutting in the valley with the fort, had closed behind
us, we halted for a moment to look down the road by which we had
first approached Fort Bayard. There, before us to the left, lay the
San José Mountain Range, grand and stately, partly covered with
cedars, pines, and firs. Winding along the foot of the range, the eye
could follow the course of the beautiful, silver-clear White Water,
bordered by willows, ash, and poplars. The most fantastic rocks rose
abruptly out of the water, here and there, covered with moss and
vines; an aloe plant or cactus generally adorning the highest point—
growing where not a handful of earth could be seen, from which
they might draw life and sustenance. To the right of us—ah! there
82. was New Mexico, its barren hills, its monotonous plains, the trail of
the serpent lying over all; for the Indians had only lately set fire to
the grass, and it had consumed the scant vegetation.
An hour's ride brought us in sight of the ruins of the San José copper
mines, on the side of the mountain. It was rather steep climbing to
reach it; but the plateau, on which the works lay, must have been a
quarter of a mile across. Placing sentinels, we inspected the old mill.
Everything was rude and primitive, but huge in dimensions; and the
different jacals that surrounded the adobe building corroborated the
guide's statement that some fifty men had been employed here,
and they had fought bravely and sold their lives dearly, he said,
the day they were attacked by the Indians, three or four years
ago.
A white man, Cecilio continued, a rebel, had led this band of
Indians, and, adding his knowledge of the habits of the white man
to the cunning of the savages, but few Americans or Mexicans could
escape these fiends. This wretch never erred in the aim he took—a
ball through the neck always sending his victim to his last account—
but here, on this spot, he had found his match. Some American,
whose name the guide had forgotten, had sent a bullet through his
traitor's heart, at last; and the Indians, never resting until the brave
man had been laid in the dust, then left this region, because,
possibly, there was nothing more to destroy. Clearing away the
brush and rubbish at our feet, the guide held up his hand—And
here, señora, he said,—pointing to two sunken graves marked by
pieces of smoothed plank,—here they are buried side by side: the
rebel who led the Indians, and the white man who killed him. It
was nothing uncommon to meet with nameless graves in this
country; but a thrill passed through my heart, as I looked at these
two mounds, where friend and foe slumbered so peacefully, side by
side.
It was dangerous to tarry long in one spot, the guide reminded us.
The orderly brought Copp and Toby, and we pursued our way
through the laughing, blooming valley. Nuts, grapes, and hops grew
83. wild here; and peaches, Cecilio said, grew near the Santa Rita
mines, but they had been planted there by the former inhabitants
and employés of the mines. The mines originally belonged to a
Spanish lady, to whose ancestors seven leagues of the country
surrounding them had been granted by the Spanish Government,
long before the territory belonged to Uncle Sam. Her representatives
had worked the mines with a force of some two hundred men, till
the Indians had overpowered them, and destroyed the works. The
immense piles of copper-ore, on either side of the road, told us that
we were nearing Santa Rita, at last; and there, just at the point of
the San José Range, lay a large, strongly-built adobe fort. Buildings
of different sizes and kinds lay clustered around this, which
appeared to be furnace and fastness at once. Placing sentinels, we
commenced exploring above ground; under-ground I refused to
venture, in my cowardice. We found works of considerable
magnitude; I counted twelve bellows, in a kind of hall, that must
have been sixty feet high, but the rafters and beams overhead had
rotted, and the weight of the mud, with which all roofs are covered
in this country, had borne down the roof, and half covered an
enormous wheel, some forty feet in diameter. Everything about this
wheel that was not wood, was copper; not a vestige of iron, steel, or
stone, was to be seen around here: it was copper, wood, and adobe.
But copper was everywhere—copper-ore, so rich that the veins
running through it could be scraped out with a penknife; copper just
smelted; copper beaten into fantastic shapes, as though the
workmen, in their despair, had meant to use these as weapons
against the Indians, when attacked here, years ago. For the same
band, with the white leader, had attacked these works; and Cecilio
showed us the dents the Indian arrows had made in the little
wooden door the men had succeeded in closing, when first attacked.
But the families of these men had lived in the buildings outside the
fort; and to rescue wife and children from death, and worse than
death, they had abandoned their place of safety in the fort, and,
with the superintendent leading them, they had fought the savages
bravely, but had been defeated and slaughtered, at last. Leaving
nine men with me, the lieutenant, guide, and three men descended
84. into the shaft, went some five hundred yards, and, on their return,
reported that everything looked as though deserted only yesterday.
Having confidence in old Cecilio, we now took the trail we had
missed the other day, as this would enable us to visit the San José
gold mine on our way back to camp. We could ride only Indian file,
but soon came to a mountain composed entirely of white flint. Sand
and earth, carried here by the wind, and bearing grass and flowers,
could be scraped aside anywhere, discovering underneath the same
semi-transparent rock. Again we took the narrow trail, which
brought us to what appeared to be the entrance to a cave, in the
side of a hill; a wooden cross was fastened over it, and a road, built
entirely by hand, led to the half-consumed remains of a number of
buildings, on the banks of a creek. The guide and lieutenant entered
the mine alone, leaving the men for my protection, but soon
returned, as fallen earth blocked up the passage near the entrance.
But oh, señora, the gold taken from this mine was something
wonderful, the guide said, enthusiastically; and there is still a
whole 'cow-skin' full of it, buried in one of these holes—pointing to
different shafts we were passing on our way to the burnt cottages.
When the Indians came here the white men tried to take it with
them, but were so closely pursued that they threw it into one of
these places, intending to come back for it; but all they could do,
later, was to bury their people decently, and the gold is still there—
left for some stranger to find.
The eyes of the soldiers—gathered around the graves we had
dismounted to see—glittered at the old guide's tale; but the sight of
these lonely, forgotten graves could awaken but one thought in my
breast: How long would it be before another group might bend over
our graves and say, I wonder who lies buried here!
85. *** END OF THE PROJECT GUTENBERG EBOOK OVERLAND TALES
***
Updated editions will replace the previous one—the old editions
will be renamed.
Creating the works from print editions not protected by U.S.
copyright law means that no one owns a United States
copyright in these works, so the Foundation (and you!) can copy
and distribute it in the United States without permission and
without paying copyright royalties. Special rules, set forth in the
General Terms of Use part of this license, apply to copying and
distributing Project Gutenberg™ electronic works to protect the
PROJECT GUTENBERG™ concept and trademark. Project
Gutenberg is a registered trademark, and may not be used if
you charge for an eBook, except by following the terms of the
trademark license, including paying royalties for use of the
Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such
as creation of derivative works, reports, performances and
research. Project Gutenberg eBooks may be modified and
printed and given away—you may do practically ANYTHING in
the United States with eBooks not protected by U.S. copyright
law. Redistribution is subject to the trademark license, especially
commercial redistribution.
START: FULL LICENSE
87. PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK
To protect the Project Gutenberg™ mission of promoting the
free distribution of electronic works, by using or distributing this
work (or any other work associated in any way with the phrase
“Project Gutenberg”), you agree to comply with all the terms of
the Full Project Gutenberg™ License available with this file or
online at www.gutenberg.org/license.
Section 1. General Terms of Use and
Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand,
agree to and accept all the terms of this license and intellectual
property (trademark/copyright) agreement. If you do not agree
to abide by all the terms of this agreement, you must cease
using and return or destroy all copies of Project Gutenberg™
electronic works in your possession. If you paid a fee for
obtaining a copy of or access to a Project Gutenberg™
electronic work and you do not agree to be bound by the terms
of this agreement, you may obtain a refund from the person or
entity to whom you paid the fee as set forth in paragraph 1.E.8.
1.B. “Project Gutenberg” is a registered trademark. It may only
be used on or associated in any way with an electronic work by
people who agree to be bound by the terms of this agreement.
There are a few things that you can do with most Project
Gutenberg™ electronic works even without complying with the
full terms of this agreement. See paragraph 1.C below. There
are a lot of things you can do with Project Gutenberg™
electronic works if you follow the terms of this agreement and
help preserve free future access to Project Gutenberg™
electronic works. See paragraph 1.E below.
88. 1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright
law in the United States and you are located in the United
States, we do not claim a right to prevent you from copying,
distributing, performing, displaying or creating derivative works
based on the work as long as all references to Project
Gutenberg are removed. Of course, we hope that you will
support the Project Gutenberg™ mission of promoting free
access to electronic works by freely sharing Project Gutenberg™
works in compliance with the terms of this agreement for
keeping the Project Gutenberg™ name associated with the
work. You can easily comply with the terms of this agreement
by keeping this work in the same format with its attached full
Project Gutenberg™ License when you share it without charge
with others.
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.
1.E. Unless you have removed all references to Project
Gutenberg:
1.E.1. The following sentence, with active links to, or other
immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project
Gutenberg™ work (any work on which the phrase “Project
89. Gutenberg” appears, or with which the phrase “Project
Gutenberg” is associated) is accessed, displayed, performed,
viewed, copied or distributed:
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.
1.E.2. If an individual Project Gutenberg™ electronic work is
derived from texts not protected by U.S. copyright law (does not
contain a notice indicating that it is posted with permission of
the copyright holder), the work can be copied and distributed to
anyone in the United States without paying any fees or charges.
If you are redistributing or providing access to a work with the
phrase “Project Gutenberg” associated with or appearing on the
work, you must comply either with the requirements of
paragraphs 1.E.1 through 1.E.7 or obtain permission for the use
of the work and the Project Gutenberg™ trademark as set forth
in paragraphs 1.E.8 or 1.E.9.
1.E.3. If an individual Project Gutenberg™ electronic work is
posted with the permission of the copyright holder, your use and
distribution must comply with both paragraphs 1.E.1 through
1.E.7 and any additional terms imposed by the copyright holder.
Additional terms will be linked to the Project Gutenberg™
License for all works posted with the permission of the copyright
holder found at the beginning of this work.
1.E.4. Do not unlink or detach or remove the full Project
Gutenberg™ License terms from this work, or any files
90. Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.
More than just a book-buying platform, we strive to be a bridge
connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.
Join us on a journey of knowledge exploration, passion nurturing, and
personal growth every day!
ebookbell.com