gpt4 book ai didi

jquery - 使用 jQuery 交换 2 个 div 的位置和 Z-Index

转载 作者:太空宇宙 更新时间:2023-11-04 15:30:29 25 4
gpt4 key购买 nike

我目前正在尝试交换两个 div 的位置以及 z-index。到目前为止,这就是我所拥有的:

$(document).ready(function()
{
$('.herotrend').click(function()
{
$(this).animate({
top: $('.herotrend:eq(1)').css('top'),
left: $('.herotrend:eq(1)').css('left'),
z: $('.herotrend:eq(1)').css('zIndex')
}, 100);

$('#music').animate({
top: $('.herotrend:eq(0)').css('top'),
left: $('.herotrend:eq(0)').css('left'),
z: $('.herotrend:eq(0)').css('zIndex')
}, 100);
});
});

这已经成功地交换了元素的位置,但我仍然无法让 z-index 也交换。

谢谢你的帮助!

最佳答案

zIndex: $('.herotrend:eq(1)').css('zIndex')

不是

z: $('.herotrend:eq(1)').css('zIndex')

关于jquery - 使用 jQuery 交换 2 个 div 的位置和 Z-Index,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13447582/

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