Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript AJAX Basics (retiring) AJAX and APIs Adding jQuery

Aaron Munoz
Aaron Munoz
11,177 Points

How are the buttons fading in and out?

This part of the excercise we added some jquery to change the class on some buttons like this.

$(document).ready(function(){
    $('button').click(function(){
        $("button").removeClass("selected");
        $(this).addClass("selected");
    });
});

When you look at the preview, every time you click on a button it fades in nicely. I can't figure out how that's happening if we're simply changing it's class? Is this something jquery does in the background somehow?

In the main.css file, look at the rule for 'ul.filter-select button'.

This properties causing the fade are at the bottom:

-webkit-transition: 0.3s; -moz-transition: 0.3s; -o-transition: 0.3s; transition: 0.3s;

You can change the value to make the fade slower or faster. Hope that helps!

In the main.css file, look at the rule for 'ul.filter-select button'.

This properties causing the fade are at the bottom:

-webkit-transition: 0.3s; -moz-transition: 0.3s; -o-transition: 0.3s; transition: 0.3s;

You can change the value to make the fade slower or faster. Hope that helps!

1 Answer

Samy Basset
Samy Basset
11,862 Points

Check the style sheet, the class selected has styling on it. When you set the new class to the button it takes the new styling.