Toggle image on click

by Gustav Persson

HTML

<script>
    function change() {
   var img1 = "http://placehold.it/350x150",
       img2 = "http://placehold.it/200x200";
   var imgElement = document.getElementById('test');
   
   imgElement.src = (imgElement.src === img1)? img2 : img1;
}
</script>
<img src="http://placehold.it/350x150" id="test" onclick ="change();"/>