Change image source with JavaScript

后端 未结 13 1876
我寻月下人不归
我寻月下人不归 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:51

    I know this question is old, but for the one's what are new, here is what you can do:

    HTML

    
    
    
    

    JAVASCRIPT

    function myFunction() {
    document.getElementById('demo').src = "myImage.png";
    }
    

提交回复
热议问题