1//change image src with jquery
2$("#myImageID").attr("src","images/my_other_image.png");
3
4//change image src plain javascript
5document.getElementById('myImageID').src="images/my_other_image.png";
6
1// https://codepen.io/kman/pen/dXjpoX
2// Stockphotos JS
3
4$(document).ready(function(){
5 var flag = 0;
6 $("button#changeSize").click(function(){
7 if(flag == 0) {
8 $("#dummyimage").attr("src","http://dummyimage.com/350x155/");
9 flag = 1;
10 }
11 else if(flag == 1) {
12 $("#dummyimage").attr("src","http://dummyimage.com/450x255/");
13 flag = 0;
14 }
15 });
16});
1//img is the attribute tag you can use #id if you want
2$("img").click(function () {
3 // Change src attribute of image
4 $(this).attr("src", "images/card-front.jpg");
5 });