1

我在fancybox 中显示内容,它在加载时不允许我使用(this)。这意味着我需要能够在不使用 (this) 的情况下提取当前悬停元素的标题并显示它。

这是我目前在 Fancybox 之外使用的

$(function() {
    $('#palette').on('mouseover', 'a', function () {
        $('#PaletteColorName').text("Color: " + this.title);
    });
    $('#palette').on('mouseleave', 'a', function () {
        $('#PaletteColorName').text("Color: ");
    });
});

当前小提琴

4

1 回答 1

2

试试this:)

$(function() {
    $('#palette').on('mouseover', 'a', function (event) {
        $('#PaletteColorName').text("Color: " + event.target.title);
    });
    $('#palette').on('mouseleave', 'a', function () {
        $('#PaletteColorName').text("Color: ");
    });
});
于 2013-08-28T16:12:45.273 回答