单击并滑动到带有jQuery的一侧并切换 [英] Slide to side with jquery on click and toggle

查看:115
本文介绍了单击并滑动到带有jQuery的一侧并切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个站点,我需要从侧面单击按钮单击div幻灯片(从左侧滑动并在右侧滑动)-在重新单击时,它应该再次滑出...因此需要从页面加载中隐藏,并且仅在单击按钮后才可见.

So i have a site where i need to have a div slide in from side with a click from a button (slide in from left and slide out on right) - and on reclick it should slide out again... So it needs to be hidden from pageload and only become visible once the button is clicked.

我试图做到这一点,但对jquery来说是新手,所以如果有人可以帮助我继续前进,我将不胜感激.

I try to make this, but im new to jquery, so if someone could help me proceed, i would appreciate it.

这是我现在走了多远的小提琴.

here is a fiddle of how far i am now.

LINK: http://jsfiddle.net/iBertel/zes8a/21/

jQuery :

$('#btn').click(function() {   
$('#div1').slideToggle('slow', function() {  
});
});

HTML :

<div id="div1">Div 1</div>
<div><a href="#" id="btn">Click</a></div>

CSS :

#div1 {
width:100px; height:100px; background-color:#F30; color:#FFF; text-align:center; font-size:30px;

}

推荐答案

$('#btn').click(function() {   
    $('#div1').animate({width:'toggle'},350);
});

http://jsfiddle.net/zes8a/39/

这篇关于单击并滑动到带有jQuery的一侧并切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆