1

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?

4
  • 1
    that should work Commented Sep 7, 2017 at 13:33
  • 1
    SO what is the issue? Commented Sep 7, 2017 at 13:34
  • 1
    Also read the documentation on add class api.jquery.com/addclass Commented Sep 7, 2017 at 13:34
  • Well thanks now I don't feel so bad haha! I have checked my script src that seems to be fine so I'm not sure where I could have gone wrong... @epascarello ill be sure to check it out thanks Commented Sep 7, 2017 at 13:39

2 Answers 2

2

Add two classes at the same time separated by space

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

Sign up to request clarification or add additional context in comments.

1 Comment

I did try this first time around but I thought that was part of my problem :') Thanks
0

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.

2 Comments

Oh damn really haha! Thanks a bunch!
Or, in the modern way: $(function(){})

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.