【问题标题】:jQuery hover over picture with two sides [duplicate]jQuery将鼠标悬停在两侧的图片上[重复]
【发布时间】:2014-07-09 09:33:10
【问题描述】:

在 jQuery 中,如何将鼠标悬停在一张图片上并显示另一张图片?我知道 hover() 需要两个参数,但我不太清楚。有人请解释一下。

【问题讨论】:

标签: javascript jquery


【解决方案1】:

这是给你的小提琴。 http://jsfiddle.net/qYb5m/

我认为您正在寻找:

$('img').hover(
    function() {
        $(this).attr();
    },
    function() {
        $(this).attr();
    }
);

如您所见。 attr() 标记有一些可自定义的选项。

失望的猫是因为如果您不发布小提琴或代码,就好像您没有尝试过。

【讨论】:

    【解决方案2】:
    $( ".your-img" ).hover(
        function() { // this function will be executed when the mouse pointer enters your img
            // try to show your second picture
        }, function() { // when the mouse pointer leaves your img
            // hide the second picture
        }
    );
    

    您可以使用 css 将第二张图片设置为默认隐藏。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-04
      • 1970-01-01
      • 2012-12-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多