gpt4 book ai didi

jquery - 使用可见性来切换隐藏元素?

转载 作者:行者123 更新时间:2023-11-28 11:38:06 25 4
gpt4 key购买 nike

请看这个 fiddle http://jsfiddle.net/rabelais/e47xq/6/

当您将鼠标悬停在缩略图上时,会显示隐藏的图像,但我想使用 visibility: hidden 而不是 display: none,这可能吗?

$(".thumnails").on("mouseover mouseout", "a", function () {
$('[title="' + $(this).attr('href') + '"]').toggle();
});

最佳答案

当然可以,只需创建自己的切换功能

$(".thumnails").on("mouseover mouseout", "a", function () {
var flag = $(this).data('flag');

$('[title="' + $(this).attr('href') + '"]').css('visibility', flag ? 'hidden' : 'visible');

$(this).data('flag', !flag);
});

FIDDLE

或拆分事件

$(".thumnails").on({
mouseover: function() {
$('[title="' + $(this).attr('href') + '"]').css('visibility', 'visible');
},
mouseout: function () {
$('[title="' + $(this).attr('href') + '"]').css('visibility', 'hidden');
}
}, 'a');

FIDDLE

关于jquery - 使用可见性来切换隐藏元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23496892/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com