本文實例講述了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程序設計有所幫助。
新聞熱點
疑難解答