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

1 Answer

Seth Kroger
Seth Kroger
56,413 Points

You attach the event handler for anchor tags before adding the anchor tags to the page. The event handler will only be attached to anchor tags that are currently on the page, but not any that would be added in the future. You can and the handler to the tags in the callback after you add them or add the handler to a parent that already exists, llike the wrapper div.

Michael Williamson
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Michael Williamson
Front End Web Development Techdegree Graduate 23,903 Points

your answer lead me to this, thank you for you guidance.

$(selector).on(event,childSelector,data,function,map)

childSelector Optional. Specifies that the event handler should only be attached to the specified child elements (and not the selector itself, like the deprecated delegate() method).

http://www.w3schools.com/jquery/event_on.asp