6.Hover


#1

I tried this and it's not working neither:

   $(document).ready(function(){

  $('div').hover(
    function(){
        $(this).addClass('active');
  });
  $('div').mouseleave(
    function(){
        $(this).removeClass('active');
  });

});

The code is working but it's not letting me pass. Any reason why?

Looking forward.


6.Hover
#2

What error are you getting ?
Your jQuery seems fine maybe error in HTML or CSS,
Please paste them in along with the error msg


#3

Hi,

This is the error message I'm getting:




But it does change the background color:


This is my HTML:

<!DOCTYPE html>
<html>
	<head>
		<title>Ghostly Divs</title>
        <link rel='stylesheet' type='text/css' href='stylesheet.css'/>
        <script type='text/javascript' src='script.js'></script>
	</head>
	<body>
        <div>Home</div>
        <div>About Us</div>
        <div>Contact</div>   
	</body>
</html>

And CSS:

border-radius: 5px;
    background-color: #ABCDEF;
    transition: background-color 0.5s ease;
    display:inline;
    font-size:25px;
    padding:20px;
    border:1px solid #ccc;
    margin-top:10px;
}

.active {
    background-color:#556677;
}

Can you spot the error?.

Looking forward,
Alejandro


#4

In your CSS I'm not sure if you missed when you copied your code or not, but you are missing div {

Other than that your code is correct, try refreshing the page


#5

I did miss it but it's there, and still the code does not allow me to pass the test.

div {
    border-radius: 5px;
    background-color: #ABCDEF;
    transition: background-color 0.5s ease;
    display:inline;
    font-size:25px;
    padding:20px;
    border:1px solid #ccc;
    margin-top:10px;
}

.active {
    background-color:#556677;
}

Is it possible that it may be a bug?

What should I do?


#6

I have the same problem...


#8

When you are testing it, its working correctly ? Hover over it wait a few seconds then remove your mouse color is changing ?

Try refreshing the page or switching to another browser


#9

It worked. I did try with another browser and it worked.

Thanks a lot.

You rock,
Alejandro


#10

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.