I have the following div and I know the selector Id of the DIV.
<div class="event">
<img src="/Content/Images/Icons/calendar1.png">
<img src="/Content/Images/Icons/calendar2.png">
<img src="/Content/Images/Icons/calendar3.png">
<img src="/Content/Images/Icons/calendar4.png">
<img src="/Content/Images/Icons/calendar5.png">
<img src="/Content/Images/Icons/calendar6.png">
</div>
I need something to find all images selector inside the div that i have so i can go change the source of the each image to a new image.
Use this code to retrieve the image URL:
$('.event img').each(function(){
alert($(this).attr('src'));
});
if you want to change the image URL then use this:
var inc = 1;
$('.event img').each(function(){
$(this).attr('src','path of image/imagename'+inc+'.imageextension');
inc++;
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With