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

How to change background color of a submit button?

There was this course on JQuery basics, and the project was creating submit form. We ended up disabling submit form in case that passwords aren't matching, and if the password had less then 8 characters.

Now i'm wondering how could I change its background color to grey while it's disabled?

1 Answer

Don't recall that class but you can just use the :disabled pseudo class to apply styles when the disabled property is true. The pseudo class is pretty well supported (including IE 9 and above).

Using pure jQuery you could either toggle a class or add CSS manually in an event handler (e.g., detecting changes to input fields). But I'd only do that if you had to support IE 8 or below (and would definitely not go the manual CSS route).