Given this HTML list and subsequent two lines of jQuery, what is the difference in the behavior of '.closest()' and '.parents()'?html Item 1 Sub Item 1 Sub Item 2 js$('.leaf').closest('.items');$('.leaf').parents('.items');

🎲 Try a Random Question  |  Total Questions in Quiz: 75  |  🧠 Study this quiz with Flashcards
This question is part of a full practice quiz:
jQuery Quiz — practice the complete quiz, review flashcards, or try a random question.

jQuery MCQs For LinkedIn Skill Assessments.


Given this HTML list and subsequent two lines of jQuery, what is the difference in the behavior of '.closest()' and '.parents()'?<br>html<br><ul class='items' id='main-menu'><br> <li><br> Item 1<br> <ul id='sub-menu'><br> <li class='leaf'>Sub Item 1</li><br> <li>Sub Item 2</li><br> </ul><br> </li><br></ul><br><br>js<br>$('.leaf').closest('.items');<br>$('.leaf').parents('.items');<br>