jQuery .slideRight 效果

标签 jquery sliding

我需要一个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/

相关文章:

jquery - Openseadragon 中的 Canvas 右键单击

java - 滑动拼图代码

JAVA JPanel同时滑出和滑入

android - 如何创建一个平滑的过渡, View 移动到覆盖在 Activity 之上?

javascript - 如何设置初始加载的默认选项卡

javascript - 使用 jQuery load() 在 Div 内的页面上加载 Javascript

javascript - 将 PHP 变量传递给 Javascript

javascript - html 元素的自定义 jQuery slider 不起作用

css - 浏览器展开、滑动动画css

悬停时 CSS 滑动下划线 - 颜色过渡不适用于已访问的链接