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


gareth connop
gareth connop
14,865 Points

How to change the image source using waypoints.js?

I am currently working on a project where I need to change the logo image by using waypoints.js. I have already used waypoints.js to make the header section fixed once it scrolls to the section below my banner, but now need to add in the image change.

My code:

$(function waypointTop(){

In the above code the id bluebar is being given a class of stuck once it scrolls to the id under-hero, so now I just need to change the source image of #logo

Any help would be appreciated.

1 Answer

The attr method is used to access DOM element attributes. Access the "src" attributes and change the path to the image if you are using an <img> tag:


Otherwise, you can change the CSS background property:

$('#logo').css('background','url:(/path/to/image) auto auto');

Something along those lines.