Learn jQuery: Traversing the DOM
In this course, you will learn about jQuery methods that allow you to access elements in the DOM, based on their relative position.
StartKey Concepts
Review core concepts you need to learn to master this subject
jQuery children
jQuery children
<div class="parent">
<div class="item">Child 1</div>
<div class="item">Child 2</div>
<div class="item">Child 3</div>
</div>
The jQuery .children()
method returns all child elements of a selected parent element.
This method only applies to the direct children of the parent element, and not deeper descendents.
In the example code, $('.parent').children()
would select all the .item
elements.
Traversing the DOM
Lesson 1 of 1
- 1jQuery makes it easy to target HTML elements by tag name, class, and id. We can also dynamically target a single element in a given class by accessing an event’s .currentTarget attribute. In this l…
- 3In addition to the .children() method we covered in the last exercise, there are two methods you can use to select the parent and siblings of an element. $(‘.choice’).on(‘click’, event => { $(ev…
- 7Understanding how elements relate to each other in the DOM makes it easy to efficiently select elements. We have covered several methods in this lesson including: - .children() to target an eleme…
What you'll create
Portfolio projects that showcase your new skills
How you'll master it
Stress-test your knowledge with quizzes that help commit syntax to memory