Dynamic Image Titles


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



Copy this code and paste it in your HTML
  1. // if an image is missing a title attribute,
  2. // adds title based on the alt attribute of the image
  3. for ( i = 0; i < document.images.length; i++ ) {
  4. if ( document.images[i].title == "" && document.images[i].alt != "" )
  5. document.images[i].title = document.images[i].alt;
  6. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.