gpt4 book ai didi

javascript - 使用 JavaScript 滑动面板

转载 作者:行者123 更新时间:2023-11-28 02:21:26 24 4
gpt4 key购买 nike

我发现的这个例子正是我正在寻找的: http://jsfiddle.net/sg3s/RZpbK/
感谢作者sg3s

jQuery(function($) {

$('a.panel').click(function() {
var $target = $($(this).attr('href')),
$other = $target.siblings('.active'),
animIn = function () {
$target.addClass('active').show().css({
right: -($target.width())
}).animate({
left: 0
}, 500);
};

if (!$target.hasClass('active') && $other.length > 0) {
$other.each(function(index, self) {
var $this = $(this);
$this.removeClass('active').animate({
left: -$this.width()
}, 500, animIn);
});
} else if (!$target.hasClass('active')) {
animIn();
}
});

});

但是我遇到了一点问题。我希望面板从右侧“打开”和“关闭”。我不熟悉 javascript,无法正确调整它。

谁能帮我解决这个问题吗?

最佳答案

像这样吗?

http://jsfiddle.net/RZpbK/845/

我所做的只是将 animIn 修改为:

            animIn = function () {
$target.addClass('active').show().css({
left: +($target.width())
}).animate({
left: 0
}, 500);
};

关于javascript - 使用 JavaScript 滑动面板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15601279/

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