Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to apply a hover element in jQuery to two divs with show and hide functionality?

There is some flickering when I use the show and hide functionality on my divs. I'm using the following code now:

$(document).ready(function(){
  $("#tekstvanitem-1").hide();
  $("#thumbnail-1").hover(function(){
   $("#tekstvanitem-1").show();
   },function(){
   $("#tekstvanitem-1").hide();


 });
});

The problem is when i rollover thumbnail-1 it show tekstvanitem-1. But because tekstvanitem-1 pops up over thumbnail-1 it then looks like its flickering because im not on thumbnail-1 anymore. So it's kind of a loop.

Is it possible to set the hover element when either my mouse is on thumbnail-1 or if my mouse is on tekstvanitem-1?

thanks in advance!

like image 386
leonidus Avatar asked Jan 03 '13 15:01

leonidus


People also ask

Can hover be applied on Div?

You can apply :hover styles to any renderable element on a page. IE6 only supports that pseudo-class on links though.

Does jQuery handle hover?

The hover() is an inbuilt method in jQuery which is used to specify two functions to start when mouse pointer move over the selected element.

Why Hover is not working on div?

You might have linked your stylesheet to your HTML file improperly. Some other CSS in the context of your project may be overriding the piece that you've given here. You might be running into browser compatibility issues with the :hover selector or something else in your code that is breaking the styling.

How do you know if an element is hover?

You can simply use the CSS :hover pseudo-class selector in combination with the jQuery mousemove() to check whether the mouse is over an element or not in jQuery. The jQuery code in the following example will display a hint message on the web page when you place or remove the mouse pointer over the DIV element's box.


1 Answers

Sure. Just put #tekstvanitem-1 in the selector...

$(document).ready(function(){
    $("#tekstvanitem-1").hide();
    $("#thumbnail-1, #tekstvanitem-1").hover(function(){
        $("#tekstvanitem-1").show();
    },function(){
        $("#tekstvanitem-1").hide();
    });
});
like image 140
Reinstate Monica Cellio Avatar answered Nov 15 '22 05:11

Reinstate Monica Cellio