I am trying to dynamically changing image src using jquery with image path from the database.
This code here is inside a form tag
<img src="images/Desert.jpg" alt="..." style="height:100px;width:200px;" class="img-thumbnail">
var j = 0;
$.each(lectObject, function(){
if (j == 1) {
$('form#unitOne img').attr({src: lectObject[2]});
}else if (j == 2) {
$('form#unitTwo img').attr({src: lectObject[2]});
}else if (j == 3) {
$('form#unitThree img').attr({src: lectObject[2]});
}else if (j == 4) {
$('form#unitFour img').attr({src: lectObject[2]});
}else if (j == 5) {
$('form#unitFive img').attr({src: lectObject[2]});
}else if (j == 6) {
$('form#unitSix img').attr({src: lectObject[2]});
}
j++
});
My concern is that, the src is succesfully change, ecause when i inspect element i see the path i want, but unfortunately the image faile to load!