Last active
August 29, 2015 14:27
-
-
Save sand3r/38531631752a40ab2bd1 to your computer and use it in GitHub Desktop.
Detect images in page without (valid) alt and title
This file contains hidden or 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
| var imagecount = 0; | |
| var titleMissing = 0; | |
| var altMissing = 0; | |
| var $image = null; | |
| jQuery('img').each(function(i, el) { | |
| imagecount++; | |
| $image = jQuery(el); | |
| if(typeof $image.attr('title') !== 'undefined' && $image.attr('title') !== '') { | |
| titleMissing++; | |
| } | |
| if(typeof $image.attr('alt') !== 'undefined' && $image.attr('alt') !== '') { | |
| altMissing++; | |
| } | |
| }); | |
| console.log(imagecount); | |
| console.log(titleMissing); | |
| console.log(altMissing); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment