jQuery can be a wizard at managing your CSS, but as with any powerful magic, it must be handled with care and consideration or you’ll end up with a giant mess!

There may be instances where modifying specific CSS properties with jQuery makes sense, but as a best practice, it’s best to maintain an organized CSS file and use jQuery to manipulate clearly defined and well-named CSS classes.

In this lesson, you learned:

  • The .css() method can change style properties of an element.
  • The .css() method can accept multiple styles at once if you pass it a JavaScript object as its argument.
  • The .animate() method can change specific style properties over a period of time.
  • The .addClass() will add a CSS class to an element, and the .removeClass() method will remove a CSS class.
  • The .toggleClass() method will toggle a class on or off an element.

Incredible work! In the next lesson, you’ll learn about logical selectors. This will enable to you add a click event to one element, and make something happen elsewhere on the page.

Sign up to start coding

By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.
Already have an account?