Mouseover and Mouseout function jQuery
Asked Answered
F

3

6

I have this script:

$("#teaser ul.buttons li").mouseover(function()
    {
        $("a",this).animate({ left: '0' },350);
    }).mouseout(function()
    {

        $("a",this).animate({ left: '-11px' },350);
    });

But when i now hover over the a element. The mouseover and mouseout going continu. How can i change this script. That when i hover of the a element. That the mouseout launch when i hover off the element.

Frequentative answered 2/3, 2011 at 11:23 Comment(1)
could you add some HTML code?Syllabism
M
7

Is http://jsfiddle.net/BBUJ7/ what you are looking for? I changed the mouseover and mouseout to hover since you mentioned hovering in the question and added a {position:relative} CSS rule.

Mazzard answered 2/3, 2011 at 11:49 Comment(0)
S
10

use mouseenter and mouseleave instead of mouseover and mouseout

Shogun answered 2/3, 2011 at 11:34 Comment(0)
M
7

Is http://jsfiddle.net/BBUJ7/ what you are looking for? I changed the mouseover and mouseout to hover since you mentioned hovering in the question and added a {position:relative} CSS rule.

Mazzard answered 2/3, 2011 at 11:49 Comment(0)
F
1

Here you have html code:

<ul class="buttons">
                    <li>
                        <h2>
                            <a class="koeriersdiensten" href="pagina.html" title="Koeriersdiensten">Koeriersdiensten
                                <span>Lorem ipsum dolor sit amet</span>
                            </a>
                        </h2>
                    </li>
                    <li>
                        <h2>
                            <a class="taxivervoer" href="pagina.html" title="Taxivervoer">Taxivervoer
                                <span>Lorem ipsum dolor sit amet</span>
                            </a>
                        </h2>
                    </li>
                </ul>
Frequentative answered 2/3, 2011 at 11:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.