Change image source with JavaScript

后端 未结 13 1874
我寻月下人不归
我寻月下人不归 2020-11-27 18:20

So I\'m new with JavaScript (this is actually my first attempt to make something work) and I\'m having a bit of trouble. I thought I had enough knowledge to make this work,

13条回答
  •  一向
    一向 (楼主)
    2020-11-27 18:58

    The problem was that you were using .src without needing it and you also needed to differentiate which img you wanted to change.

    function changeImage(a, imgid) {
        document.getElementById(imgid).src=a;
    }
    

提交回复
热议问题