Created
August 17, 2022 16:00
-
-
Save webmasterninjay/a25d5121d272fde335aa47744b5b1889 to your computer and use it in GitHub Desktop.
add title to all images from alt tags using jQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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