I need to add alt text to various images which do not have IDs or anything else to identify the images from one another other there the image file names.
Is there a way to add alt text to each image based on what the image file name is?
Here's an example of the code I started working on, but it obviously doesn't work and I'm not even sure I am heading in the right direct. Any help would be much appreciated.
<script>
document.onload = function(){
img.setAttribute('src', 'icons-vegan.png');
img.setAttribute('alt', 'Vegan Icon');
img.setAttribute('title', 'Vegan Icon');
}
document.onload = function(){
img.setAttribute('src', 'icons-gluten.png');
img.setAttribute('alt', 'Gluten Icon');
img.setAttribute('title', 'Gluten Icon');
}
</script>