6

我有这个脚本:

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

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

但是当我现在将鼠标悬停在 a 元素上时。mouseover 和 mouseout 继续进行。我怎样才能改变这个脚本。当我悬停a元素时。当我将鼠标悬停在元素上时,mouseout 启动。

4

3 回答 3

10

使用mouseenterandmouseleave代替mouseoverandmouseout

于 2011-03-02T11:34:24.070 回答
7

http://jsfiddle.net/BBUJ7/你在找什么?我将mouseoverand更改mouseout悬停,因为您在问题中提到悬停并添加了a {position:relative}CSS 规则。

于 2011-03-02T11:49:43.847 回答
1

这里有html代码:

<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>
于 2011-03-02T11:30:44.310 回答