Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Instant jQuery Selectors

You're reading from   Instant jQuery Selectors Learn how to master the art of effectively using jQuery's selectors

Arrow left icon
Product type Paperback
Published in Aug 2013
Publisher Packt
ISBN-13 9781783282210
Length 70 pages
Edition 1st Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
Aurelio De Rosa Aurelio De Rosa
Author Profile Icon Aurelio De Rosa
Aurelio De Rosa
Arrow right icon
View More author details
Toc

Preface

jQuery is a popular JavaScript library designed to simplify the client-side scripting of HTML, widely used by most of the websites on the Internet. It helps you to manipulate elements, and create fancy interactive websites in a very easy way that is compatible with modern and older browsers as well.

Instant jQuery Selectors will take you as a beginner and turn you into an expert that knows all of the tips and tricks of the pros about the jQuery's basic element: selectors. Through the use of examples, you'll be able to start using selectors efficiently and easily to solve your day-to-day problems.

What this book covers

Setting up jQuery (Must know) explains how to download and include jQuery in a web page and a good rule of thumb to choose between the two major jQuery branches, 1.X and 2.X.

The All selector (Must know) covers the All (or Universal) selector, to select all of the elements of a document.

Selecting by ID (Must know) introduces the ID selector and how jQuery manages it behind the scenes.

Selecting by class (Must know) describes the Class selector and how to optimize it for older browsers.

Selecting by tag (Must know) demonstrates the use of the Element selector and how you can use it in conjunction with other selectors.

Multiple selectors at once (Should know) shows how to use more than one selector in a single call.

Selecting by hierarchy (Must know) covers the hierarchy operators that allow you to retrieve elements by their relationship in the DOM.

Selecting by attributes (Should know) describes how many and what are the selectors to collect elements by their attributes.

Selecting by position using filters (Should know) introduces filters, and in particular those that allow to filter a collection using the elements' positions inside the collection itself.

Selecting from elements using filters (Should know) covers filters specific to form elements.

Child filters (Should know) describes filters to target node's children.

Other filters (Become an expert) shows the filters not covered in the previous recipes.

Custom filters (Become an expert) explains how to create a custom filter using two approaches.

Context matters (Should know) shows how to use the second parameter of the jQuery constructor in order to improve performance.

Improving performance re-using selected elements (Become an expert) demonstrates how to store a collection of previously selected elements in a variable for a later processing and how this method can improve performances.

Methods to filter collections (Become an expert) covers how many and what are the jQuery's methods to filter a collection.

Traversing DOM SubTrees (Become an expert) describes how many and what are the methods that can be applied to a collection, to find elements starting from a matched set.

How to have efficient selectors (Become an expert) explains tips and tricks to improve the performances of a website by simply selecting elements in the right way.

What you need for this book

This book assumes the reader to have a basic understanding of HTML and CSS. In addition, having basic knowledge of JavaScript, its syntax, and some concepts like anonymous functions, events, DOM and callbacks would be beneficial.

Who this book is for

The book is for web developers who want to delve into jQuery, the most popular and adopted JavaScript framework, from its very starting point: selectors. Even if you're already familiar with the framework and its selectors, you could find several tips and tricks that you aren't aware of, especially about performance and how jQuery acts behind the scenes.

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.

Code words in text are shown as follows: "We can include other contexts through the use of the include directive."

A block of code is set as follows:

<!DOCTYPE html>
<html>
   <head>
      <meta charset="UTF-8">
      <title>Instant jQuery Selector How-to</title>
   </head>
   <body>
   </body>
</html>

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

<script src="jquery-1.10.1.min.js"></script>
    <script>
        $(document).ready(function() {
            $('*').css('border', '2px solid #000000');
        });
    </script>

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "clicking the Next button moves you to the next screen".

Note

Warnings or important notes appear in a box like this.

Tip

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 send an e-mail to , and mention the book title via the subject of your message.

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

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image