我使用ajax上传图像。使用ajax重新加载图像jquery
我想让这个函数与类名而不是id一起使用。
$(document).ready(function(){
var button = $('#uploader'), interval;
new AjaxUpload(button, {
action: 'upload.php',
onSubmit : function(file , ext){
if (! (ext && /^(jpg|png|jpeg|gif)$/.test(ext))){
alert('Error: Only images are allowed');
return false;
} else {
// Image Accepted.
}
},
onComplete: function(file, response){
button.attr("src", response);
}
});
});
在HTML
<img id="uploader" src="" />
工作正常,但我想添加更多的img标签。
请建议我怎样才能改变这个函数类,而不是IDS
<img class="uploader" src="" />
<img class="uploader" src="" />
IMG标签是动态创建 –