I have this HTML:
<div id="allSteps">
<h3>Intermediate steps</h3>
<span class="staticStep">→ <img src="" alt="intermediate step" class="image" ></span>
<span class="staticStep">→ <img src="" alt="intermediate step" class="image"></span>
<span class="staticStep">→ <img src="" alt="intermediate step" class="image"></span>
</div>
In javaScript, how do I access the .src for each image?
I tried the following but it gives me an error:
document.querySelector(".staticStep img").src[0] = images[num][0];
document.querySelector(".staticStep img").src[1] = images[num][1];
document.querySelector(".staticStep img").src[2] = images[num][2];
I also tried the following but it gives me a an error:
document.querySelector(".staticStep img")[0].src = images[num][0];
document.querySelector(".staticStep img")[1].src = images[num][1];
document.querySelector(".staticStep img")[2].src = images[num][2];
What am I doing wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…