jQuery控制的不同方向的滑動(向左、向右滑動等)
引入jquery.js,復(fù)制以下代碼,即可運行。
<style type="text/css"> .slide { position: relative; height: 200; lightyellow; } .slide .inner { position: absolute; left: 0; bottom: 0; height: 100; lightblue; width: 100% } </style>
1、slidetoggle() 交替slidedown(),slideup()
Html代碼
<div id="slidebottom" class="slide"> <button> slide it </button> <div class="inner"> Slide from bottom </div> </div>
Js代碼
$('#slidebottom button').click(function() { $(this).next().slideToggle(); });
2、左側(cè)橫向交替滑動 Animate Left
Html代碼
<div id="slidewidth" class="slide"> <button> slide it </button> <div class="inner"> Slide from bottom </div> </div>
Js代碼
$("#slidewidth button").click(function(){ $(this).next().animate({width: 'toggle'}); });
3、左側(cè)橫向交替滑動 Animate Left Margin (非隱藏)
Html代碼
<div id="slideleft" class="slide" style="width: 50%;float: right"> <button> slide it </button> <div class="inner"> Slide from bottom </div> </div>
Js代碼
$("#slideleft button").click(function(){ var $lefty = $(this).next(); $lefty.animate({ left:parseInt($lefty.css('left'),10)==0 ? -$lefty.outerWidth() : 0 }); });
4、右側(cè)橫向滑動Slide to right
Html代碼
<div id="slidemarginleft" class="slide" style="width: 60%;float: left"> <button> slide it </button> <div class="inner"> Slide from bottom </div> </div>
Js代碼
$("#slidemarginleft button").click(function(){ var $marginlefty = $(this).next(); $marginlefty.animate({ marginLeft:parseInt($marginlefty.css('marginLeft'),10)==0 ? $marginlefty.outerWidth() : 0 }); });
相關(guān)文章
jQuery實現(xiàn)橫向帶緩沖的水平運動效果(附demo源碼下載)
這篇文章主要介紹了jQuery實現(xiàn)橫向帶緩沖的水平運動效果,涉及jQuery中鼠標(biāo)事件及animate方法使用技巧,并附帶demo源碼供讀者下載參考,需要的朋友可以參考下2016-01-01ztree獲取選中節(jié)點時不能進(jìn)入可視區(qū)域出現(xiàn)BUG如何解決
zTree 是一個依靠 jQuery 實現(xiàn)的多功能 “樹插件”。優(yōu)異的性能、靈活的配置、多種功能的組合是 zTree 最大優(yōu)點。本文給大家介紹ztree獲取選中節(jié)點時不能進(jìn)入可視區(qū)域出現(xiàn)BUG如何解決的相關(guān)資料,對ztree獲取選中節(jié)點感興趣的朋友一起學(xué)習(xí)吧2015-12-12BootStrap的table表頭固定tbody滾動的實例代碼
本文給大家分享一段關(guān)于BootStrap的table表頭固定tbody滾動的實例代碼,代碼簡單易懂,需要的朋友可以參考下2016-08-08jQuery EasyUI的TreeGrid查詢功能實現(xiàn)方法
這篇文章主要介紹了jQuery EasyUI的TreeGrid查詢功能實現(xiàn)方法,需要的朋友可以參考下2017-08-08jquery easyui combobox模糊過濾(示例代碼)
這篇文章主要介紹了jquery easyui combobox模糊過濾(示例代碼)。需要的朋友可以過來參考下,希望對大家有所幫助2013-11-11