I attempted to modify the source of an image by clicking on smaller ones using bootstrap’s template found at . Despite my efforts, I have not been able to achieve the desired result. (Any help is greatly appreciated!)
I included id="myImage" on the main image tag
<img class="img-responsive" id="myImage" src="img1.jpg">
and added onClick="changeImage()" to the smaller images
<div class="col-sm-3 col-xs-6">
<a href="#" onClick="changeImage()">
<img class="img-responsive portfolio-item" src="img2.jpg">
</a>
</div>
The script function is:
<script type="text/javascript">
function changeImage() {
if(document.getElementById('myImage').src == 'img1.jpg') {
document.getElementById('myImage').src = 'img2.jpg';
} else if(document.getElementById('myImage').src == 'img2.jpg') {
document.getElementById('myImage').src = 'img1.jpg';
}
}
</script>
(Any assistance would be much appreciated!)