Use Image Alt for Image Title


/ Published in: JavaScript
Save to your folder(s)

Firefox ignores the alt tag on images and uses the title tag whereas IE uses the alt tag. This javascript code copies the text in all image alts to the image's title. Best when placed at the footer of each page


Copy this code and paste it in your HTML
  1. <script type="text/javascript">
  2. var images = document.getElementsByTagName('img');
  3. for (i = 0; i < images.length; i++)
  4. {
  5. images[i].title = images[i].alt;
  6. }
  7. </script>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.