Blinking div and mouseover/mouseout events and Prototype?

user1856596

I have this JS code:

$$('.someclass').each(function(elem) {
    elem.observe('mouseover', function() {
        elem.next().show();
    });

    elem.observe('mouseout', function() {
        elem.next().hide();
    });
});

The elem.next() points to a div which has display:none as style. When I put the mouse over the watched element, the div is show, but it starts blinking. When I move the mouse, it blinks like crazy. I also trie mouseenter and mouseleave instead with the same result. I want the div to appear and not to blink. When the mouse is moved out of the div, it should disappear again. This is the HTML:

<div class="someclass">
    <a href="...">
        <img src="...">
    </a>
</div>
<div style="display: none;">my div that should not blink</div>

Any idea what might be wrong?

Geek Num 88

The mouseout and mouseover events are constantly firing because of the structure of your HTML.

Because you have a <a href> as well as a <img> within the div you are observing the mouseover event is bubbled up from those elements and hits the observer on the div. Also because the cursor is not technically on top of the <div> the mouseout event fires as well.

I put together this http://jsfiddle.net/pkA5n/ and tried it in all the browsers I have available to me on my Windows Desktop (IE10/Chrome/Firefox) and I saw no blinking.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Div blinking while resize

From Dev

JavaScript's onmouseover and onmouseout events causing blinking

From Dev

jQuery clickable blinking text div

From Dev

Blinking issue of span with div hover

From Dev

How to add blinking effect for the dynamically generated div

From Dev

CSS hide div on mouse hover but it is blinking

From Dev

Handling events inside a class (Prototype)

From Dev

Blinking a div with background-color in jquery using setInterval

From Dev

blinking and flicker when updating div contents from ajax

From Dev

jQuery fadein and fadeout another div on hover / mouseleave without blinking

From Dev

Div tag events in jquery

From Dev

Div tag events in jquery

From Dev

I use jquery blinking functionality to parent div.but that effects chaild div.please help how to solve

From Dev

How to handle click events on div

From Dev

Stacking DIV Click Events for Javascript

From Dev

jQuery events to new created div

From Dev

How to manage events on a specific div?

From Dev

Jquery clone div breaking events

From Dev

Stacking DIV Click Events for Javascript

From Dev

How to detect all events added on a div

From Dev

Stop children of a DIV from firing events

From Dev

Allow pointer events to pass through a nested div

From Dev

div overlap in IE 11 blocks events

From Dev

observe scrolling in div doenst work for future events

From Dev

Using click events to change the div in "focus"?

From Dev

IE 9, 10: div structure and events

From Dev

events on 2 div at the same time on mouse over

From Dev

Stop children of a DIV from firing events

From Dev

Dragging DIV with JavaScript mouse events moves to quickly

Related Related

HotTag

Archive