1
votes

On hover functionality is not moving perfect. This is my code and when a mouse is placed over Details* text then whole div color changed to black. But the functionality is not working fine. I want whenever mouse is placed over details text then it should call the hover function but right now its not working fine. Any recommendations?

$('#disclaimer').hover(
        function () {
            $('#wrapper').addClass('hovered');
        }, function () {
            $('#wrapper').removeClass('hovered');
        }
    );
4

4 Answers

3
votes

Try this :

script :

$('#disclaimer').hover(
            function () {
                $('#wrapper').addClass('hover');
            }, function () {
                $('#wrapper').removeClass('hover');
            }
        );

style :

.hover {
    display : block;
    background-color : black;
}
/* new css */
.hover #Image_Car { display: none; }
.hover #ctaBtn {    display: none; }
.hover #Image_logo {    display: none; }
.hover #headlineText {     display: none; }

Fiddle : http://jsfiddle.net/U4EF8/7/

1
votes
  $("#searchput").hover(function() {
     $('#wrapper').addClass("hover");
}, function() {
     $('#wrapper').removeClass("hover");
});
1
votes

Here is the Code :

$(document).ready(function(){
 $( "#disclaimer" )
 .mouseover(function() {
      $('#wrapper').addClass('hovered');
 })
.mouseout(function() {
   $('#wrapper').removeClass('hovered');
  });

 });

and my html is :

  <div id="wrapper"></div>
  <div id="disclaimer" style="border:1px solid black;">
    hello    
    </div> 

Here is the working example : http://jsbin.com/heduqesu/2/edit , you can check in console that class is added and removed on mouse enter and mouse leave event . Hope this helps . Cheers!

0
votes

did you already try this ?

$('#disclaimer').mouseenter(
    function () {
        $('#wrapper').addClass('hovered');
    }
);
$('#disclaimer').mouseleave(
    function () {
        $('#wrapper').removeClass('hovered');
    }
);

or with pure css

#disclaimer:hover { 
     //put any attribute on "hovered" class here
}

or maybe i don't understand your question enough.