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!
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
ardon Bailey
3,750 PointsI was trying to implement jquery into page
I was trying to make up a page on CodePen after watching some videos on here and can't figure out why the Jquery isn't working. Any help is appreciated! Thanks
5 Answers

Andrew Chalkley
Treehouse Guest Teacherhttp://codepen.io/chalkers/pen/jrCeI
return false
prevents the default browsers behaviour of going to another page.

ardon Bailey
3,750 PointsThanks, Andrew Chalkley I want to make sure I have a full understanding. We return false because it stops the code from looping?

Andrew Chalkley
Treehouse Guest TeacherNot really, it's not looping. Because you're clicking on an anchor or an a
tag the browser's default behaviour is to jump to the linked page. Writing a click handler doesn't override the the browsers default behaviour it adds additional behaviour. Returning false tells the browser to stop doing it's default behaviour in other words it tells the browser not to follow the link to the linked page.
Good question.

ardon Bailey
3,750 PointsAh! Thanks for the explanation. It definitely seems like bad practice for me to put a click handler on all of my anchor tags (I need to id or class them). Take care.

Andrew Chalkley
Treehouse Guest TeacherNot really.
If a users JavaScript is switched off you still want there to be a link that will go to a page that shows the content. Alternatively if it's on the same page you could have an id on the div e.g. #events and a link to #events and it will jump down to it when you click on the link.
Regards Andrew