Programmatically change the src of an img tag

后端 未结 9 1827
执念已碎
执念已碎 2020-11-22 04:31

How can I change the src attribute of an img tag using javascript?


         


        
9条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-22 05:35

    Give your image an id. Then you can do this in your javascript.

    document.getElementById("blaah").src="blaah";
    

    You can use the ".___" method to change the value of any attribute of any element.

提交回复
热议问题