【发布时间】:2014-05-23 20:28:08
【问题描述】:
我正在使用带有 jQuery 的 Dropzone.js 将文件上传到服务器。上传文件后,我正在使用当前 url 生成一个“服务器端”文件名。
$('.dropzone').dropzone({
init: function() {
this.on('success', function(file) {
var newname = generateServersideFilename(file.name); // this is my function
// here I need a help to find the thumbnail <img> to set the 'src' attribute
}
}
});
如何找到当前缩略图img来设置src属性?
【问题讨论】:
-
不是最好的方法,但可以工作:
$('span:contains("'+file.name+'")').closest('.dz-preview').find('img').attr('src', newname);- 如果你知道更好的方法,请分享。
标签: javascript jquery dropzone.js