Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Michael Williams
PLUS
Michael Williams
Courses Plus Student 8,059 Points

Is there an intuitive (or intuitive-ish) way to know which order to put my properties in?

In the code below, I played around with property order until it worked, but is there a rule of thumb for knowing which order to put the properties in?

event.target.previousElementSibling.className = 'highlight' ;

1 Answer

Brendan Whiting
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brendan Whiting
Front End Web Development Techdegree Graduate 84,735 Points

Print out the 'event' object to the console, open up the chrome dev tools, and do some poking around at it's properties. There's a lot in there.

There's the event object that get's passed in to an event handler function when something is clicked or a similar event. It has a property called target, which is the element that was clicked. It's a DOM element, and it has references to other DOM elements that are nearby in the "family tree" of elements- one of which is previousElementSibling. And DOM elements have a property called className which is their class.