我正在尝试将src中的“ www”替换为“ refresh”,以收集具有“ cover”类的图像。
let testing = document.querySelectorAll(".cover");
for (index = 0; index < testing.length; index++) {
var x = document.querySelectorAll(".cover");
x.src = x.src.replace("www", "refresh");
}
答案 0 :(得分:3)
尝试
let testing = document.querySelectorAll(".cover");
testing.forEach(function(el) {
el.src = el.src.replace("www", "refresh");
});