Hey i'm trying to change the image without the id. We can't change html so i can't use an id.
I have this:

        <img src="images/start.png" alt="start">
        <figcaption>Nog geen thema gekozen</figcaption>

And in my script:
document.querySelector('src') = "images/mode.png";
I don't know how to select it and change it.

Attribution to http://www.liangshunet.com/en/202005/494917182.htm
Read more there but here's their Javascript attempt (seems to work.)

<script type="text/javascript">
              function ChangeImgSrcWithoutId() {
                     var arrImg = document.images;
                     for (var i = 0; i < arrImg.length; i++) {
                            if (arrImg[i].getAttribute("tSrc") != undefined) {
                                   arrImg[i].src = arrImg[i].getAttribute("tSrc");
              ChangeImgSrcWithoutId(); // Call

If you're using jQuery (which it doesn't look like you are, but I thought i'd just mention it in case), you can do something as simple as $('figure img) to find all images that are children of figures, or $('img[src="images/start.png"]) to find all images that have images/start.png as their source URI, etc.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.