Skip to content

Instantly share code, notes, and snippets.

@webmasterninjay
Created August 17, 2022 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webmasterninjay/a25d5121d272fde335aa47744b5b1889 to your computer and use it in GitHub Desktop.
Save webmasterninjay/a25d5121d272fde335aa47744b5b1889 to your computer and use it in GitHub Desktop.
add title to all images from alt tags using jQuery
<script>
jQuery(document).ready(function($) {
$("img:not([title])").each(function() {
if($(this).attr("alt") != '') $(this).attr("title", $(this).attr("alt"));
else $(this).attr("title", $(this).attr("src"));
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment