jQuery怎么实现左右滑动的toggle jquery实现左右滑动的toggle方法

 2022-10-20    316  

有的朋友可能对于“jQuery怎么实现左右滑动的toggle jquery实现左右滑动的toggle方法”还有很多不明白的地方,下面由77ISP云服务器技术小编为大家讲解一下,下面我们来一起看看吧!

这次给大家带来jQuery怎么实现左右滑动的toggle,jQuery实现左右滑动toggle的注意事项有哪些,下面就是实战案例,一起来看一下。

我们知道使用 jQuery 来实现上下移入移除,可以直接使用 slideUp() 和 slideDown() 方法。

slideUp()方法和slideDown()方法只会改变元素的高度。如果一个元素的 display 属性值为 “none”,当调用 slideDown() 方法时,这个元素将由上至下延伸显示。slideUp()方法正好相反,元素将由上到下缩短隐藏。

代码如下:

toggle-jquery1.9
 
 
  p.container {
   height: 320px;
   border: 1px solid #ccc;
  }
  p.left {
   width: 200px;
   height: 300px;
   background-color: #36f;
  }
 


 

$(document).ready(function(){ $('#toggle').click(function(){ $('.left').slideToggle(300); }); });

那么,要实现左右的滑入滑出呢?

demo 如下:

toggle-jquery1.9
 
 
  p.container {
   height: 320px;
   border: 1px solid #ccc;
  }
  p.left {
   width: 200px;
   height: 300px;
   background-color: #36f;
  }
 


 

$(document).ready(function(){ $('#toggle').click(function(){ $('.left').animate({width:'toggle'},350); }); });

效果如下:

以上就是“jQuery怎么实现左右滑动的toggle jquery实现左右滑动的toggle方法”的详细内容,更多请关注77isp云服务器技术网其它相关文章!

原文链接:https://77isp.com/post/3249.html

=========================================

https://77isp.com/ 为 “云服务器技术网” 唯一官方服务平台,请勿相信其他任何渠道。