Silvia RamosFront End Web Development Techdegree Graduate 18,306 Points
prev() Hey, sorry but I didn't quite understand why she is using prev() to access the different buttons? Can someone explain this for "dummies"? haha I understood what the prev method is used for with those lists examples, but I can't get it right on this project?
Thank you! :)))
Steven Parker203,990 Points
The purpose of traversal is to get a reference to an element starting with a reference to another element.
The "prev()" method gets a reference to the element just before the one it is used on. So if you click on a button, the
$(event.target) refers to the button itself, and using "prev()" on that refers to the span just before it:
<span style="display: none">Darth Vader is ... <span> <!-- $(event.target).prev() --> <button>Reveal Spoiler</button> <!-- $(event.target) -->
Does that help?