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

JavaScript Introduction to jQuery Hello, jQuery! Accessing and Modifying Attributes

I'm not sure what I am doing wrong

I have been following along with this video and when I click on "Go somewhere else", it takes me to Google but doesn't log it in the console. Same with the link to Github. What am I missing? Here is my code:

    <a href="https://www.google.com/">Go somewhere else!</a>
    <button>Change Destination</button>

$('button').on('click', function() {
    $('a').attr('href', 'https://github.com/');

2 Answers

Steven Parker
Steven Parker
225,726 Points

I think you're misunderstanding the JavaScript code.

This code doesn't intercept or alter the link function, so nothing will be logged when you click the link.

However, when you click the "Change Destination" button, it will log the new destination location that the link will be ready to take you to.

jason chan
jason chan
31,008 Points

Go somewhere else is HTML anchor tag.

Change destination is the button you create with jquery to go to github.