如何更改脚本以填充src
中包含的.seperate-group
图片,将A
中上传的图片与FOR A
和{{1}相匹配} B
?
FOR B

var $ = uploadcare.jQuery;
var widgets = uploadcare.initialize(); // get all widget instances
widgets.forEach(function(widget) {
widget.onUploadComplete(function(fileInfo) {
var group = $(widget.inputElement).closest(".group"); // find a group the instance is related to
$(group).find('.feature-img').each(function(i, img) { // find image tags in the group
img.src = fileInfo.cdnUrl; // update previews
});
});
});

.image-input {
display: block;
position: relative;
height: 100px;
width: 200px;
}
.container {
display: flex;
}
.image-preview-wrapper {
height: 50px;
}
.feature-img {
height: 100%;
}
.seperate-group img {
height: 100px;
width: 100px;
}

答案 0 :(得分:1)
Kyle,试试这段代码
var $ = uploadcare.jQuery;
var widgets = uploadcare.initialize(); // get all widget instances
widgets.forEach(function (widget) {
widget.onUploadComplete(function (fileInfo) {
var group = $(widget.inputElement).parent().parent(); // find a group the instance is related to
$(group).find('.feature-img').each(function (i, img) { // find image tags in the group
img.src = fileInfo.cdnUrl; // update previews
});
});
});