【问题标题】:Mouseover and Mouseout function jQuery鼠标悬停和鼠标悬停功能jQuery
【发布时间】:2011-07-07 05:02:45
【问题描述】:

我有这个脚本:

$("#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 会启动。

【问题讨论】:

  • 你能添加一些 HTML 代码吗?

标签: jquery mouseover mouseout


【解决方案1】:

使用mouseentermouseleave 代替mouseovermouseout

【讨论】:

    【解决方案2】:

    http://jsfiddle.net/BBUJ7/ 是您要找的吗?我将mouseovermouseout 更改为hover,因为您在问题中提到了悬停并添加了a {position:relative} CSS 规则。

    【讨论】:

      【解决方案3】:

      这里有 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>
      

      【讨论】: