Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Learning jQuery - Fourth Edition
  • Table Of Contents Toc
  • Feedback & Rating feedback
Learning jQuery - Fourth Edition

Learning jQuery - Fourth Edition

4.2 (20)
close
close
Learning jQuery - Fourth Edition

Learning jQuery - Fourth Edition

4.2 (20)

Overview of this book

To build interesting, interactive sites, developers are turning to JavaScript libraries such as jQuery to automate common tasks and simplify complicated ones. Because many web developers have more experience with HTML and CSS than with JavaScript, the library's design lends itself to a quick start for designers with little programming experience. Experienced programmers will also be aided by its conceptual consistency. LearningjQuery - Fourth Edition is revised and updated version of jQuery. You will learn the basics of jQuery for adding interactions and animations to your pages. Even if previous attempts at writing JavaScript have left you baffled, this book will guide you past the pitfalls associated with AJAX, events, effects, and advanced JavaScript language features. Starting with an introduction to jQuery, you will first be shown how to write a functioning jQuery program in just three lines of code. Learn how to add impact to your actions through a set of simple visual effects and to create, copy, reassemble, and embellish content using jQuery's DOM modification methods. The book will take you through many detailed, real-world examples, and even equip you to extend the jQuery library itself with your own plug-ins.
Table of Contents (24 chapters)
close
close
Learning jQuery Fourth Edition
Credits
Foreword
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

DOM traversal methods


After creating a jQuery object using $(), we can alter the set of matched elements we are working with by calling one of these DOM traversal methods. DOM traversal methods are discussed in detail in Chapter 2, Selecting Elements.

Filtering

Traversal method

Returns a jQuery object containing…

.filter(selector)

Selected elements that match the given selector.

.filter(callback)

Selected elements for which the callback function returns true.

.eq(index)

The selected element at the given 0-based index.

.first()

The first selected element.

.last()

The final selected element.

.slice(start, [end])

Selected elements in the given range of 0-based indices.

.not(selector)

Selected elements that do not match the given selector.

.has(selector)

Selected elements that have a descendant matching selector.

Descendants

Traversal method

Returns a jQuery object containing…

.find(selector)

Descendant elements that match the selector.

.contents()

Child nodes (including text nodes).

.children([selector])

Child nodes, optionally filtered by a selector.

Siblings

Traversal method

Returns a jQuery object containing…

.next([selector])

The sibling immediately following each selected element, optionally filtered by a selector.

.nextAll([selector])

All siblings following each selected element, optionally filtered by a selector.

.nextUntil([selector], [filter])

All siblings following each selected element up to and not including the first element matching selector, optionally filtered by an additional selector.

.prev([selector])

The sibling immediately preceding each selected element, optionally filtered by a selector.

.prevAll([selector])

All siblings preceding each selected element, optionally filtered by a selector.

.prevUntil([selector], [filter])

All siblings preceding each selected element up to and not including the first element matching selector, optionally filtered by an additional selector.

.siblings([selector])

All siblings, optionally filtered by a selector.

Ancestors

Traversal method

Returns a jQuery object containing…

.parent([selector])

The parent of each selected element, optionally filtered by a selector.

.parents([selector])

All ancestors, optionally filtered by a selector.

.parentsUntil([selector], [filter])

All ancestors of each selected element up to and not including the first element matching selector, optionally filtered by an additional selector.

.closest(selector)

The first element that matches the selector, starting at the selected element and moving up through its ancestors in the DOM tree.

.offsetParent()

The positioned parent, either relative or absolute of the first selected element.

Collection manipulation

Traversal method

Returns a jQuery object containing…

.add(selector)

The selected elements, plus any additional elements that match the given selector.

.addBack()

The selected elements, plus the previous set of selected elements on the internal jQuery stack.

.end()

The previous set of selected elements on the internal jQuery stack.

.map(callback)

The result of the callback function when called on each selected element.

.pushStack(elements)

The specified elements.

Working with selected elements

Traversal method

Description

.is(selector)

Determines whether any matched element is matched by the given selector expression.

.index()

Gets the index of the matched element in relation to its siblings.

.index(element)

Gets the index of the given DOM node within the set of matched elements.

$.contains(a, b)

Determines whether DOM node b contains DOM node a.

.each(callback)

Iterates over the matched elements, executing callback for each element.

.length

Gets the number of matched elements.

.get()

Gets an array of DOM nodes corresponding to the matched elements.

.get(index)

Gets the DOM node corresponding to the matched element at the given index.

.toArray()

Gets an array of DOM nodes corresponding to the matched elements.

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech

Create a Note

Modal Close icon
You need to login to use this feature.
notes
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Delete Note

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Edit Note

Modal Close icon
Write a note (max 255 characters)
Cancel
Update Note

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY