Question 10
Back to Exercise
The page contains this HTML:
<ul id="menu">
<li>Home</li>
<li>Courses</li>
</ul>What does the following JavaScript code print when it runs on this page?
const menu = document.getElementById("menu");
menu.addEventListener("click", (e) => {
console.log(e.target.tagName, e.currentTarget.tagName, e.target.textContent);
});
menu.children[1].click();
- A UL UL Courses
- B LI LI Courses
- C UL LI Home
- D LI UL Courses Correct
Correct Answer: Option D
target is the clicked li; currentTarget is the ul whose listener is running. tagName is upper-case in HTML documents.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!