Javascript 将文件放入区域样式中
有一个pluploader,它有一个文件放置区,其id为Javascript 将文件放入区域样式中,javascript,jquery,css,html,plupload,Javascript,Jquery,Css,Html,Plupload,有一个pluploader,它有一个文件放置区,其id为dropFilesHere var uploader = new plupload.Uploader({ drop_element : "dropFilesHere", /*...*/ }); 如果用户将文件放在放置区上,我想对其进行一些更改*(如gmail文件附件) *例如: .mouse_over{ border-width:5px border-style:dashed #80808
dropFilesHere
var uploader = new plupload.Uploader({
drop_element : "dropFilesHere",
/*...*/
});
如果用户将文件放在放置区上,我想对其进行一些更改*(如gmail文件附件)
*例如:
.mouse_over{
border-width:5px border-style:dashed #808080;
}
样本:
我该怎么做
uploader.bind('Init',函数(up,params){
$('#filelist').html(“当前运行时:+params.runtime+”);
如果(params.runtime==='html5'){
$('#dropfiles here')。在({
“dragenter”:函数(){
$(this.addClass('mouse_over');
},
“dragleave drop”:函数(){
$(this.removeClass('mouse_over');
}
});
}
});
您是否尝试过使用CSS:悬停
选择器
.dropFilesHere:hover {
border-width:5px border-style:dashed #808080;
}
您还可以使用$('.dropFilesHere').mouseout()和$('.dropFilesHere').mouseenter()或纯$('.dropFilesHere').hover()为客户端附加jQuery触发器
无论如何,现在使用CSS总是更好,因为它有时比JS更有效。如果初始化的运行时是html5,您可以尝试以下方法:
// the runtime has been initialized :
var uploader = $(item).pluploadQueue();
if(uploader.runtime === 'html5') {
$('li.plupload_droptext').bind('dragenter', function() {
$(this).css("border", "5px dashed #000000");
});
$('li.plupload_droptext').bind('dragleave', function() {
$(this).css("border", "0px none");
});
}
在Chrome18和Firefox11上测试。
希望这能有所帮助
我意识到另一个问题是不允许在降落区外降落…Hi!这是可行的,但不是我需要的方式。如果用户拖动文件并将光标移到div区域上,我希望应用这种样式。看这幅画!谢谢,我一直在找这个!我做了一些更改(使用on,添加drop事件,将此代码放到uploader的init部分),请参阅我的更新问题。不确定更新代码的“.on”(仍然没有升级到jq1.7…)Thx:-)
// the runtime has been initialized :
var uploader = $(item).pluploadQueue();
if(uploader.runtime === 'html5') {
$('li.plupload_droptext').bind('dragenter', function() {
$(this).css("border", "5px dashed #000000");
});
$('li.plupload_droptext').bind('dragleave', function() {
$(this).css("border", "0px none");
});
}