Unit 1 excercise 12


#1



Unit 1 excercise 12

I am getting my code approved but the button doesnt do what we want it to do... My question now is: when you want the div to:
- be opacity=0.5 in normal state
- be opacity= when mouseenter
- be 0.5 again when the mouse leaves

Do you have to place $('div') in the new line of code again?


$(document).ready (function()   { 
    $('div').mouseenter(function() {
        $('div').fadeTo('fast',1);
        });
    .mouseleave() {
     $('div').fadeTo('fast',0,5);   
    }
    
    });


#2

$(document).ready (function()   { 
    $('div').mouseenter(function() {
        $('div').fadeTo('fast',1);
        });
    .mouseleave() {
     $('div').fadeTo('fast',0,5);   
    }
    
    });

For method chaining, do not terminate with a ; inside the chain.

    $('div').mouseenter(function() {

    })
    .mouseleave(function() {

    });

Consider using this inside the handler so it only affects the actual element under the mouse pointer.

    $(this).fadeTo('fast', 1);

#3

You've got few typos and some other errors.

Should be 0.5 and not 0,5

See suggestion below:

$(document).ready(function(){
    $('div').mouseenter(function(){
        $('div').fadeTo('fast', 1);
        }); $('div').mouseleave(function(){
            #('div').fadeTo('fast', 0.5);
            });
    });

#4

Hi guys, I have tried both your solutions and they do not work... Nothing happens when hovering over the button. This is the code right now:

$(document).ready(function(){
$('div').mouseenter(function(){
$('div').fadeTo('fast', 1)
}) $('div').mouseleave(function(){
('div').fadeTo('fast', 0.5)
});
});


#5

I passed with this,

$(document).ready(function() {
    $('div').mouseenter(function() {
        $(this).fadeTo('fast',1);
    })
    .mouseout(function() {
        $(this).fadeTo('fast',0.5);
    });
});

Be sure to read the instructions at the bottom of the full screen view. Submit. Wait a second. Mouse over, pause, mouse off, pause 2 seconds, return to editor.