Ajax拖放頁面元素(圖片)

最近了解了一點YUI的控件知識.先做個Ajax拖放頁面元素(圖片)以便學習參考.

現在有一些網站如QQ空間,都允許用戶自定義模塊,可以任意拖動模塊到各個地方去.YUI在這一方面做得比較好.下面以一組圖片的方式來說明如何運用Ajax拖放頁面元素:

第一步:在<head></head>標簽中加入YUI文件的三個鏈接:yahoo-dom-event.js\ainmation.js\dragdrop.js

然后是我們自己的腳本:ddlist.js還有我直接寫在html文檔里面的javascript代碼:

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>任意拖放圖片到某一個區位</title>
<script src="js/yahoo-dom-event.js"></script>
<script src="js/animation.js"></script>
<script src="js/dragdrop.js"></script>
<script src="js/ddlist.js"></script>
<style type="text/css">
li{ list-style:none;float:left;margin:0 16px 16px 0;}
.sortList{ width:202px;}
ul{width:800px;}
</style>
</head>


?

<body>
<div class="SlideShow"><ul id="ul1" class="dropList"><li id="li0" class="sortList"><img src="images/img01.jpg" width="200" height="150"/></li><li id="li1" class="sortList"><img src="images/img02.jpg" width="200" height="150"/></li><li id="li2" class="sortList"><img src="images/img03.jpg" width="200" height="150"/></li><li id="li3" class="sortList"><img src="images/img04.jpg" width="200" height="150"/></li><li id="li4" class="sortList"><img src="images/img05.jpg" width="200" height="150"/></li></ul>
</div>
</body>

?在上面的body中要注意寫好各個調用的ID。。如id="ul1"

?

第二步:實現Ajax拖放頁面元素

<script type="text/javascript">var Dom = YAHOO.util.Dom;var Event = YAHOO.util.Event;var DDM = YAHOO.util.DragDropMgr;YAHOO.DDApp = {init: function(){new YAHOO.util.DDTarget("ul1");for(var i=0;i<7;i++){new YAHOO.DDList("li"+i);    }}    };Event.onDOMReady(YAHOO.DDApp.init,YAHOO.DDApp,true);
</script>

首先是初始化三個變量。你會注意到,所有函數和變量名都以YAHOO開頭:

?其次在加載頁面時,我們需要告訴YUI和瀏覽器我們需要拖動哪些元素。在這里我們要拖動<ul>和其中所有的<li>。。所以把前者設置為一個DDTarget,后者設置為DDList所有實例。

Event.onDOMReady(YAHOO.DDApp.init,YAHOO.DDApp,true);

這個是Event.onDOMReady是一個定制YUI事件。當DOM準備好操時就會觸發這個事件。到此我們實現了所有功能。

?

轉載于:https://www.cnblogs.com/kimcastle/archive/2012/06/16/2551725.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/274750.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/274750.shtml
英文地址,請注明出處:http://en.pswp.cn/news/274750.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

你不知道的vscode之空間控制

大家好&#xff0c;我是若川。持續組織了8個月源碼共讀活動&#xff0c;感興趣的可以點此加我微信 ruochuan12 參與&#xff0c;每周大家一起學習200行左右的源碼&#xff0c;共同進步。同時極力推薦訂閱我寫的《學習源碼整體架構系列》 包含20余篇源碼文章。歷史面試系列王志遠…

正則表達式說明

參考地址&#xff1a; 正則表達式說明 正則表達式全部符號解釋轉載于:https://www.cnblogs.com/s-bridge/archive/2012/06/26/2564396.html

lynda ux_UX心態

lynda uxI have had the pleasure of training and mentoring several UX people at the beginning of their careers.在職業生涯的初期&#xff0c;我很高興接受培訓和指導。 Whatever your background or experience, I’ve found repeatedly that there are some key miles…

什么 Leader 值得追隨?

大家好&#xff0c;我是若川。持續組織了8個月源碼共讀活動&#xff0c;感興趣的可以點此加我微信 ruochuan12 參與&#xff0c;每周大家一起學習200行左右的源碼&#xff0c;共同進步。目前建有江西|湖南|湖北 籍 前端群&#xff0c;想進群的可以加我微信 ruochuan12 進群。歷…

pico8 掌機_使用Pico-8構建自己的復古游戲

pico8 掌機An example of the kinds of pixel animations people make in Pico-8.人們在Pico-8中制作的各種像素動畫的示例。 Are you a fan of old school video games? What if I told you there’s an NES-style game devkit with the sound/sprite/code tools all built i…

C#中Brush、Color、String相互轉換

1、String轉換成Color Color color (Color)ColorConverter.ConvertFromString(string); 2、String轉換成Brush BrushConverter brushConverter new BrushConverter(); Brush brush (Brush)brushConverter.ConvertFromString(string); 3、Color轉換成Brush Brush …

實用 JavaScript 調試技巧

大家好&#xff0c;我是若川。持續組織了8個月源碼共讀活動&#xff0c;感興趣的可以點此加我微信 ruochuan12 參與&#xff0c;每周大家一起學習200行左右的源碼&#xff0c;共同進步。同時極力推薦訂閱我寫的《學習源碼整體架構系列》 包含20余篇源碼文章。歷史面試系列。另外…

數據挖掘 點擊更多 界面_6(更多)技巧,可快速改善用戶界面

數據挖掘 點擊更多 界面重點 (Top highlight)Creating beautiful, usable, and efficient UIs takes time, with many design revisions along the way.創建漂亮&#xff0c;可用和高效的UI需要花費時間&#xff0c;并且在此過程中進行了許多設計修訂。 Making those constant…

簡單的ASP.NET無刷新分頁

1、新建一個分頁存儲過程&#xff1a; CREATE procedure [dbo].[P_Pager] (PageNumber int, PageSize int) as declare sql nvarchar(4000) set sql select top Convert(varchar, PageSize) * from T_Test where [type]1 and id not in (select top Convert(…

Koa在實際的業務場景中,路由如何做分割?【文末留言送書】

大家好&#xff0c;我是若川。文末留言送書&#xff0c;具體規則文末說明。另外為了鼓勵大家多寫源碼共讀筆記&#xff0c;我會在寫了5次及以上筆記的作者群里也抽獎送這本書。以后也會有更多福利傾斜。導讀&#xff1a;Koa是一個Node框架&#xff0c;在Node開源社區中&#xf…

設計模式_設計

設計模式Thanks for my colleague WanChing‘s help to prepare this sharing article. E-Commerce app collects plentiful products from various brands. Each brand has its brand signature colors and public image. This article introduces how we made a single page …

動態切換css

方法一&#xff1a;給link一個id&#xff0c;直接獲取該DOM操作href <link rel"stylesheet" id"stylelink" type"text/css"/> <a href"#" οnclickjavascript:document.getElementById("stylelink").href "…

使用 GTD 優化自己的工作和生活

大家好&#xff0c;我是若川。持續組織了8個月源碼共讀活動&#xff0c;感興趣的可以點此加我微信 ruochuan12 參與&#xff0c;每周大家一起學習200行左右的源碼&#xff0c;共同進步。同時極力推薦訂閱我寫的《學習源碼整體架構系列》 包含20余篇源碼文章。歷史面試系列。另外…

模仿不再受寵若驚

If you haven’t heard of the Jio-Zoom plagiarism clash, you’re probably living under a rock (which may not be a bad idea given the state of the world right now). The turf war between Jio Meet and Zoom began when the Indian telecom giant ripped off the Chi…

一個計算機愛好者的不完整回憶(二十八)關于計算機書籍

我只在大學階段在圖書館看了很多計算機方面的書&#xff0c;無論已經老得都殘破了還是最新出版的。前兩天又看到論壇中有關于計算機書籍特別是國內人士編寫或翻譯的計算機書籍的評論的文章&#xff0c;譚浩強老先生又毫無懸念的被牽連了進來。也發表一下自己的一些觀點吧。   …

Vue2剝絲抽繭-響應式系統 系列

大家好&#xff0c;我是若川。持續組織了8個月源碼共讀活動&#xff0c;感興趣的可以點此加我微信 ruochuan12 參與&#xff0c;每周大家一起學習200行左右的源碼&#xff0c;共同進步。同時極力推薦訂閱我寫的《學習源碼整體架構系列》 包含20余篇源碼文章。歷史面試系列。另外…

word文本樣式代碼樣式_使用文本樣式表達創建真相來源

word文本樣式代碼樣式As of After Effects 17.0, you can use expressions to edit text styles in After Effects. Here’s why this would transform your workflow:從After Effects 17.0開始&#xff0c;您可以使用表達式在After Effects中編輯文本樣式。 這就是這將改變您的…

mvn備忘

創建web工程 mvn archetype:generate -DgroupIdcom.malangmedia -DartifactIdautoDeployToJetty -DarchetypeArtifactIdmaven-archetype-webapp -Dversion1.0 添加jetty插件 <project xmlns"http://maven.apache.org/POM/4.0.0" xmlns:xsi"http://www.w3.or…

前端框架源碼解讀之Vite

前端工具鏈十年盤點&#xff1a;https://mp.weixin.qq.com/s/FBxVpcdVobgJ9rGxRC2zfgWebpack、Rollup 、Esbuild、Vite ?webpack: 基于 JavaScript 開發的前端打包構建框架&#xff0c;通過依賴收集&#xff0c;模塊解析&#xff0c;生成 chunk&#xff0c;最終輸出生成的打包…

hp-ux_UX中的格式塔-或-為什么設計師如此討厭間距

hp-uxI’ve been lucky so far in my design career to have worked with engineers that seem genuinely interested in learning about design. Perhaps, as mentioned in the title, it’s more about them trying to figure out why it matters so much to us that there i…