首页 > 编程 > JavaScript > 正文

jQuery实现可拖拽的许愿墙效果【附demo源码下载】

2019-11-20 09:00:01
字体:
来源:转载
供稿:网友

本文实例讲述了jQuery实现可拖拽的许愿墙效果。分享给大家供大家参考,具体如下:

运行效果图如下:

这里简单介绍下功能点:

① 随机显示背景图或背景色
② 出现的位置随机
③ 可以通过拖拽改变位置

好了,附上代码:

<!doctype html><html lang="en"><head>  <meta charset="UTF-8"/>  <title>许愿墙</title>  <link rel="stylesheet" href="base.min.css"/>  <style>  #wish{height:650px;margin:20px;position:relative;width:960px;}  .wish{background:url(wish_bg.png) no-repeat 0 0;color:#000;height:166px;padding:10px 20px 30px 20px;width:185px;}  .wish-close{background:url(wish_close_bg.png) no-repeat 0 0;display:none;position:absolute;right:5px;top:-5px;width:17px;height:17px;}  </style></head><body>  <ul id="wish">    <li>11111</li>    <li>22222</li>    <li>33333</li>    <li>44444</li>    <li>55555</li>  </ul></body></html><script src="jquery.min.js"></script><script src="jquery-ui.min.js"></script><script src="wish.js"></script><script>$(function(){  $('#wish').wish();  $('.wish').draggable({containment:'#wish',scroll:false});});</script>

注意:

jqueryui 需要加载 draggable 和 scale Effect,draggable 是支持拖拽,而 scale Effect 是点击关闭的效果。

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

更多关于jQuery相关内容感兴趣的读者可查看本站专题:《jQuery拖拽特效与技巧总结》、《jQuery常用插件及用法总结》、《jquery中Ajax用法总结》、《jQuery表格(table)操作技巧汇总》、《jQuery扩展技巧总结》、《jQuery常见经典特效汇总》、《jQuery动画与特效用法总结》及《jquery选择器用法总结

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

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