gpt4 book ai didi

jQuery .slideRight 效果

转载 作者:行者123 更新时间:2023-12-03 21:38:28 26 4
gpt4 key购买 nike

我需要一个div标签在屏幕右侧滑出,如何使用jQuery获得这种效果?我一直在看这里:http://api.jquery.com/category/effects/sliding/而且这似乎不是我要找的......

最佳答案

如果您愿意包含 jQuery UI库,除了jQuery本身,那么你可以简单地使用hide(), with additional arguments ,如下:

$(document).ready(
function(){
$('#slider').click(
function(){
$(this).hide('slide',{direction:'right'},1000);

});
});

JS Fiddle demo .

<小时/>

无需使用 jQuery UI,您只需使用 animate() 即可实现您的目标:

$(document).ready(
function(){
$('#slider').click(
function(){
$(this)
.animate(
{
'margin-left':'1000px'
// to move it towards the right and, probably, off-screen.
},1000,
function(){
$(this).slideUp('fast');
// once it's finished moving to the right, just
// removes the the element from the display, you could use
// `remove()` instead, or whatever.
}
);

});
});

JS Fiddle demo

如果您选择使用 jQuery UI,那么我建议您链接到 Google 托管的代码,地址为:https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/jquery-ui.min.js

关于jQuery .slideRight 效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4229422/

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