jquery拖动层效果插件用法实例分析(附demo源码)


Posted in Javascript onApril 28, 2016

本文实例讲述了jquery拖动层效果插件用法。分享给大家供大家参考,具体如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Drag Drop Panels - Web Developer Plus Demos</title>
<script type="text/javascript" src="js/jquery-1.3.2.js" ></script>
<script type="text/javascript" src="js/jquery-ui-1.7.2.custom.min.js" ></script>
<link rel="stylesheet" type="text/css" href="styles.css" />
<script type="text/javascript" >
$(function(){
  $('.dragbox')
  .each(function(){
    $(this).hover(function(){
      $(this).find('h2').addClass('collapse');
    }, function(){
      $(this).find('h2').removeClass('collapse');
    })
    .find('h2').hover(function(){
      $(this).find('.configure').css('visibility', 'visible');
    }, function(){
      $(this).find('.configure').css('visibility', 'hidden');
    })
    .click(function(){
      $(this).siblings('.dragbox-content').toggle();
    })
    .end()
    .find('.configure').css('visibility', 'hidden');
  });
  $('.column').sortable({
    connectWith: '.column',
    handle: 'h2',
    cursor: 'move',
    placeholder: 'placeholder',
    forcePlaceholderSize: true,
    opacity: 0.4,
    stop: function(event, ui){
      $(ui.item).find('h2').click();
      var sortorder='';
      $('.column').each(function(){
        var itemorder=$(this).sortable('toArray');
        var columnId=$(this).attr('id');
        sortorder+=columnId+'='+itemorder.toString()+'&';
      });
      alert('SortOrder: '+sortorder);
      /*Pass sortorder variable to server using ajax to save state*/
    }
  })
  .disableSelection();
});
</script>
</head>
<body>
  <h3>Drag n Drop Panels</h3>
  <div class="column" id="column1">
    <div class="dragbox" id="item1" >
      <h2>Handle 1</h2>
      <div class="dragbox-content" >
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vestibulum velit ultricies orci pharetra elementum. In massa mauris, varius sed tempus a, iaculis sed erat. Ut sollicitudin tellus mollis arcu laoreet semper. Suspendisse ut felis odio. Aliquam auctor, tortor sit amet suscipit elementum, nunc ante dictum lectus, ac accumsan justo nunc sed velit. Sed sollicitudin varius tortor vitae varius. Aliquam interdum, nisl consectetur laoreet commodo, metus massa sagittis nisl, non venenatis lacus mi nec tortor. Ut malesuada auctor dolor, id pulvinar est malesuada sed. Aliquam sed posuere orci. 
      </div>
    </div>
    <div class="dragbox" id="item2" >
      <h2><span class="configure" ><a href="#" >Configure</a></span>Handle 2</h2>
      <div class="dragbox-content" >
        Phasellus porttitor adipiscing lacus ac tempus. Vivamus gravida augue metus, eu cursus nisl. Etiam arcu eros, placerat sed rhoncus at, porta et elit. Aenean pharetra ante neque. Aenean id egestas orci. Suspendisse potenti. Nunc at magna leo, sed porta erat. Proin eget neque turpis, vel blandit massa. Donec vel tortor magna. Curabitur id nibh magna, nec hendrerit nibh. 
      </div>
    </div>
    <div class="dragbox" id="item3" >
      <h2>Handle 3</h2>
      <div class="dragbox-content" >
        Proin porttitor euismod condimentum. Integer suscipit nibh nec augue facilisis ut commodo nisi ornare. Nam sed mauris vitae justo convallis placerat. Curabitur viverra, ipsum id volutpat sollicitudin, mi nisi condimentum nulla, nec dapibus velit libero eget orci. Nam purus lectus, imperdiet pharetra pulvinar ac, sodales sit amet sem. Ut vel mollis ante. Vivamus consectetur varius risus eu hendrerit. Sed scelerisque euismod leo, quis accumsan justo venenatis eu. Ut risus lorem, aliquet id fermentum nec, auctor ut enim. Ut pretium elementum turpis vel dignissim. 
      </div>
    </div>
  </div>
  <div class="column" id="column2" >
    <div class="dragbox" id="item4" >
      <h2>Handle 4</h2>
      <div class="dragbox-content" >
        Nullam metus magna, tristique vel ultrices a, molestie quis dolor. Curabitur porta porta ullamcorper. Duis varius velit et dui auctor pretium bibendum urna gravida. Sed euismod dui in tellus euismod euismod. Nam convallis ornare fermentum. Aliquam libero augue, ullamcorper vitae lacinia at, vestibulum et risus. Praesent accumsan ultrices purus eu consequat. Phasellus posuere lobortis malesuada. Curabitur ac orci eu dui vulputate porttitor. Sed a urna et odio vulputate euismod. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. In volutpat, tortor eu dapibus vestibulum, risus metus eleifend ipsum, quis lobortis elit dolor vel ligula. Aliquam ultrices nunc in elit bibendum pharetra. Ut non ante sagittis arcu imperdiet posuere. Duis consectetur massa sit amet enim scelerisque consequat et eget magna. Curabitur tristique molestie sem quis vulputate. Sed eleifend urna neque. Nam placerat eros non augue consequat vestibulum. 
      </div>
    </div>
    <div class="dragbox" id="item5" >
      <h2>Handle 5</h2>
      <div class="dragbox-content" >
        Nam rhoncus sodales libero, et facilisis nisi volutpat et. Nullam tellus eros, consequat eget tristique ultricies, rhoncus vitae magna. Duis nec scelerisque orci. Nullam a enim est, et eleifend nunc. Proin dui eros, vulputate eget consectetur quis, ultrices ac sem. Nulla aliquam metus eu magna placerat placerat. Suspendisse eget tellus turpis, et ultricies nisi. Etiam in diam mi, sed tincidunt eros. Phasellus convallis aliquam arcu, vitae fringilla quam pharetra sed. In at augue at nibh placerat feugiat at id elit. Curabitur sit amet quam ut turpis molestie blandit in vel nulla. 
      </div>
    </div>
  </div>
  <hr style="clear:both;" />
<p>
Demo Provided By: <a href="http://webdeveloperplus.com" title="Web Developer Plus - Ultimate Web Development & Design Resource" >Web 
Developer Plus</a></p>
</body>
</html>

完整实例代码点击此处本站下载。

希望本文所述对大家jQuery程序设计有所帮助。

Javascript 相关文章推荐
一些mootools的学习资源
Feb 07 Javascript
Javascript 入门基础学习
Mar 10 Javascript
用Javascript实现Sleep暂停功能代码
Sep 03 Javascript
jQuery插件Skippr实现焦点图幻灯片特效
Apr 12 Javascript
前端js实现文件的断点续传 后端PHP文件接收
Oct 14 Javascript
easyui 中的datagrid跨页勾选问题的实现方法
Jan 18 Javascript
AngularJS表格样式简单设置方法示例
Mar 03 Javascript
React 无状态组件(Stateless Component) 与高阶组件
Aug 14 Javascript
微信小程序使用wxParse解析html的实现示例
Aug 30 Javascript
Vue开发环境中修改端口号的实现方法
Aug 15 Javascript
如何在JavaScript中创建具有多个空格的字符串?
Feb 23 Javascript
利用Vue实现简易播放器的完整代码
Dec 30 Vue.js
JS模仿手机端九宫格登录功能实现代码
Apr 28 #Javascript
jQuery实现的鼠标经过时变宽的效果(附demo源码)
Apr 28 #Javascript
Bootstrap Chart组件使用教程
Apr 28 #Javascript
jQuery内容折叠效果插件用法实例分析(附demo源码)
Apr 28 #Javascript
location.hash保存页面状态的技巧
Apr 28 #Javascript
字符串反转_JavaScript
Apr 28 #Javascript
使用 stylelint检查CSS_StyleLint
Apr 28 #Javascript
You might like
Discuz! 5.0.0论坛程序中加入一段js代码,让会员点击下载附件前自动弹出提示窗口
2007/04/18 PHP
php记录日志的实现代码
2011/08/08 PHP
php stripslashes和addslashes的区别
2014/02/03 PHP
php中PDO方式实现数据库的增删改查
2015/05/17 PHP
PHP调用其他文件中的类
2018/04/02 PHP
JS鼠标滑过图片时切换图片实现思路
2013/09/12 Javascript
javascript进行数组追加方法小结
2014/06/16 Javascript
javascript模拟实现ajax加载框实例
2014/10/15 Javascript
jQuery中bind()方法用法实例
2015/01/19 Javascript
javascript中call和apply的用法示例分析
2015/04/02 Javascript
js实现具有高亮显示效果的多级菜单代码
2015/09/01 Javascript
smartcrop.js智能图片裁剪库
2015/10/14 Javascript
归纳下js面向对象的几种常见写法总结
2016/08/24 Javascript
js给table赋值的实例代码
2016/10/13 Javascript
基于Bootstrap的标签页组件及bootstrap-tab使用说明
2017/07/25 Javascript
ES6 中可以提升幸福度的小功能
2018/08/06 Javascript
jQuery时间戳和日期相互转换操作示例
2018/12/07 jQuery
Vue-input框checkbox强制刷新问题
2019/04/18 Javascript
vue el-table实现自定义表头
2019/12/11 Javascript
[02:43]DOTA2英雄基础教程 半人马战行者
2014/01/13 DOTA
pycharm在调试python时执行其他语句的方法
2018/11/29 Python
Python 批量读取文件中指定字符的实现
2020/03/06 Python
Python数据可视化实现多种图例代码详解
2020/07/14 Python
python3:excel操作之读取数据并返回字典 + 写入的案例
2020/09/01 Python
python 利用Pyinstaller打包Web项目
2020/10/23 Python
详解修改Anaconda中的Jupyter Notebook默认工作路径的三种方式
2021/01/24 Python
html5响应式开发自动计算fontSize的方法
2020/01/13 HTML / CSS
高性能装备提升营地:Kammok
2019/02/27 全球购物
一些网络技术方面的面试题
2014/05/01 面试题
大学生个人自我鉴定
2013/12/03 职场文书
中学生社区服务活动报告
2015/02/05 职场文书
2015年团支书工作总结
2015/04/03 职场文书
保险内勤岗位职责
2015/04/13 职场文书
老乡会致辞
2015/07/28 职场文书
诚信教育主题班会
2015/08/13 职场文书
MySQL COUNT函数的使用与优化
2021/05/10 MySQL