首页 > 编程 > JavaScript > 正文

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

2019-11-20 10:11:38
字体:
来源:转载
供稿:网友

本文实例讲述了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相关内容感兴趣的读者可查看本站专题:《jQuery切换特效与技巧总结》、《jQuery拖拽特效与技巧总结》、《jQuery扩展技巧总结》、《jQuery常见经典特效汇总》、《jQuery动画与特效用法总结》、《jquery选择器用法总结》及《jQuery常用插件及用法总结

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

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表