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 jQuery Basics (2014) Creating a Mobile Drop Down Menu Using parent(), hasClass() and prop()

Kamila Mielczarek
Kamila Mielczarek
3,294 Points

What's the difference between "prop" used here and "attr"?

I kinda jumped ahead and completed this beforehand (Googled for "select - preselected") and found <option selected>. Assuming it would accept true or false, I made this:

if ( anchor.parent().hasClass("selected") ) { option.attr("selected", true); }

And it works all right. What's the difference between "prop" and "attr" in this case?

By the way I found this case (http://stackoverflow.com/questions/5874652/prop-vs-attr) and kind of see the difference between those as in prop being able to return objects etc.