2013-03-08 57 views
3

我正在使用jquery 1.9。我有問題實現上傳圖像使用拖放,但當我放在div圖像然後其重定向和打開圖像在瀏覽器中我有jsfiddle實現代碼請檢查並告訴我什麼問題,爲什麼它被重定向爲什麼頁面被重定向時,我把圖像放在div上

這是我的以下代碼

$(document).on('ready',function(){ 
    jQuery.event.props.push('dataTransfer'); 
    $('.dropuploader').bind('drop', function(e){ 
     $(this).css({'box-shadow' : 'none', 'border' : '4px dashed rgba(0,0,0,0.2)'}); 
     alert("hello there"); 
     return false; 
    }); 
    $('.dropuploader').bind('dragenter', function(e){ 
     $(this).css({'box-shadow' : 'inset 0px 0px 20px rgba(0, 0, 0, 0.1)', 'border' : '4px dashed #bb2b2b'}); 
     return false; 
    }); 

}); 

回答

3

你已經錯過了ondragover="return false"使用下面的div HTML

<div class="dropuploader" ondragover="return false">Upload here</div>> 

inst ead of

<div class="dropuploader">Upload here</div> 
相關問題