change the src value of an image based on the options value in a select box

后端 未结 4 1241
闹比i
闹比i 2020-12-14 13:34

I have an img tag and a select box




  
  
  

Javascript:

function setImage(select){
  var image = document.getElementsByName("image-swap")[0];
  image.src = select.options[select.selectedIndex].value;
}  

Example there

提交回复
热议问题