代码结构:
js代码:
drag_append:function(){
var self = this;
var appender = null;
$('.ullis').find('.lis').on('mousedown',function(event){
var e = window.event||arguments[0];
var niu = $(this).clone();
var a = self.pic_change(niu.html());
appender = $(a);
var cur_Pos = $(this).offset();
$('#for_drag').append(appender);
$('#for_drag').css({'display':'block','top':cur_Pos.top,'left':cur_Pos.left,'position':'absolute'});
$('#for_drag').css({'width':'94px','height':'94px','z-index':'51'});
$('#for_drag').trigger(event);
$('#for_drag').css('z-index','51');
var posX = $('#for_drag').offset().left;
var posY = $('#for_drag').offset().top;
$(document).bind('mousemove',function(){
var e = window.event||arguments[0];
var Nposx = e.clientX - posX;
var Nposy = e.clientY - posY;
$('#for_drag').css({'top':(Nposy+'px'),'left':(Nposx+'px')})
})
$(document).bind('mouseup',function(){
$(document).unbind('mousemove');
$(document).unbind('mouseup')
})
});
在拖动的时候总是出现禁止图标,没法拖动,请问该怎么破?
刚又看了一下,是拖动时如果碰到相邻元素,会出现禁止符号 ,该怎么破??
目标元素加两个事件ondragenter ondragover事件内容为event.preventDefault()
给元素添加 draggable="true"