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 .attr() confusion

in jquery we get or set attribute using .attr() in .attr() getter method we can get only one attribute of any element , we cant get more than one is there any way to do that

1 Answer

Steven Parker
Steven Parker
231,141 Points

You can get get one attribute at a time, which you can assign to a variable or use in an expression. A single expression can use the "attr" function more than once if you need to access more than one attribute.

If you could get more than one with a single operation, what kind of result would expect from that operation and how might you use it?