Michael Hands
Michael Hands

Reputation: 67

jQuery adding multiple classes

The goal is to add the two classes to any divs with the class .title.

Here is my code:

$(document).ready(function() {

  $('#welcome').mouseenter(function() {

      $('.title').addClass('animated').addClass('swing');
    
  });

});

Is this the best way to do this?

Upvotes: 1

Views: 3214

Answers (2)

Matt Andrews
Matt Andrews

Reputation: 2878

You have an error:

$document.ready(function() {   }

should be:

$(document).ready(function() {   }

If you look in your browser's developer tools, you'll see syntax errors like this in the Console tab.

Here's a working version.

Upvotes: 0

sarath
sarath

Reputation: 459

Add two classes at the same time separated by space

$('.title').addClass('animated swing')

Upvotes: 2

Related Questions