Use HTML DOM to change the value of the image's src attribute - Javascript DOM

Javascript examples for DOM:Quiz

Description

Use HTML DOM to change the value of the image's src attribute

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<img id="image" src="smiley.gif" width="304" height="228">

<script>
document.getElementById("image").src = "http://java2s.com/resources/a.png";
</script>/*from ww w .ja  v a  2  s  .  com*/

</body>
</html>

Related Tutorials