Example
<!DOCTYPE html>
<html>
<head>
<title>onClick Demo</title>
</head>
<body>
<script>
function toggleImage() {
var img1 = "http://placehold.it/350x150";
var img2 = "http://placehold.it/200x200";
var imgElement = document.getElementById('toggleImage');
imgElement.src = (imgElement.src === img1)? img2 : img1;
}
</script>
<img src="http://placehold.it/350x150" id="toggleImage" onclick="toggleImage();"/>
</body>
</html>
Most Helpful This Week
jQuery example of scroll to top
How to declare multiple variables in one statement in Javascript?
JavaScript check if first string contains all characters of second string
JavaScript sort multi dimensional array on specific columns
How to scroll page to 1000px from top on page load using jQuery?
jQuery get the coordinates of div clicked