Challenge: Navigate the DOM Hierarchy
メニューを表示するにはスワイプしてください
Task
You have a simple task list in HTML. Your goal is to navigate through the DOM hierarchy using properties like parentNode, childNodes, firstChild, lastChild, previousSibling, and nextSibling to understand their behavior and how they access different nodes.
- Access the Parent Node: The
<li>element with the IDcurrent-taskis selected. Access its parent<ul>element; - Access All Child Nodes: Retrieve all child nodes, including text nodes (like whitespace);
- Access the First and Last Child Nodes:
- Access the first child node on the parent
<ul>; - Access the last child node on the parent
<ul>.
- Access the first child node on the parent
- Navigate to Sibling Nodes:
- Access its previous sibling node on
current-task; - Access its next sibling node on
current-task.
- Access its previous sibling node on
index.html
index.css
index.js
- Use
parentNodeto access its parent<ul>element. - Use
childNodeson the parent<ul>to retrieve all child nodes, including text nodes (like whitespace); - Use
firstChildon the parent<ul>to access the first child node; - Use
lastChildon the parent<ul>to access the last child node; - Use
previousSiblingoncurrent-taskto access its previous sibling node; - Use
nextSiblingoncurrent-taskto access its next sibling node.
index.html
index.css
index.js
すべて明確でしたか?
フィードバックありがとうございます!
セクション 2. 章 5
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください
セクション 2. 章 5