首頁 > web前端 > js教程 > 主體

基于jquery实现的鼠标拖拽元素复制并写入效果_jquery

WBOY
發布: 2016-05-16 18:03:11
原創
1148 人瀏覽過

直接上代码:

复制代码 代码如下:





鼠标拖拽复制效果


<script> <BR>$(function(){ <BR>$("#left li").click(function(e) { <BR>var index=$(this).index(); <BR>$("#left li").removeClass("selected"); <BR>$(this).addClass("selected"); <BR>$("#right ul").removeClass('show'); <BR>$("#right ul").addClass('hide'); <BR>$("#right ul").eq(index).removeClass('hide'); <BR>$("#right ul").eq(index).addClass('show'); <BR>}); <br><br><BR>$("#left ul li").mousemove(function(e) { <BR>if($(this).attr('class')!='selected'&&$(".clone").length>0) <BR>{ <BR>$(this).addClass('over'); <BR>} <BR>}); <BR>$("#left ul li").mouseout(function(e) { <BR>if($(this).attr('class')!='selected') <BR>{ <BR>$(this).removeClass('over'); <BR>} <BR>}); <BR>$("#left ul li").mouseup(function(e) { <BR>if($(this).attr('class')!='selected'&&$(".clone").length>0) <BR>{ <BR>var index=$(this).index(); <BR>//$("#right ul").eq(index).prepend($(".clone")); <BR>$(".clone").appendTo($("#right ul").eq(index)); <BR>$(".clone").attr('class',''); <BR>} <BR>}); <BR>$("#right ul li").mousedown(function(e) {//鼠标按下,鼠标变移动标志,克隆元素,并确定新克隆元素位置 <BR>$(this).clone().addClass("clone").appendTo($("body")); <BR>$("body").css('cursor','move'); <BR>$(".clone").css('left',e.clientX+1); <BR>$(".clone").css('top',e.clientY+1); <br><br>}); <BR>$(document).mousemove(function(e){ <BR>if($(".clone").length>0) <BR>{ <BR>$(".clone").css('left',e.clientX+1); <BR>$(".clone").css('top',e.clientY+1); <BR>} <BR>}); <BR>$(document).mouseup(function(e){ <BR>$(".clone").remove(); <BR>$("body").css('cursor','auto'); <BR>}); <BR>}); <BR></script>





  • 组一

  • 组2

  • 组3






相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!