Created
August 11, 2013 12:05
-
-
Save residualmind/6204605 to your computer and use it in GitHub Desktop.
Simple lazy QA check for ALT, TARGET, TITLE attributes in A and IMG tags. Include and execute globally, then cry or swear // 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
function lazyQACheck(){ | |
$("a").each(function(){ | |
if( $(this).attr("title") === undefined || $(this).attr("title") === "" ) { | |
console.warn("QA: <A> tag with TEXT \"" + $(this).text() + "\" has no TITLE attribute"); | |
} | |
if( $(this).attr("href") && $(this).attr("target") === undefined && !!(1+$(this).attr("href").indexOf("//")) ) { | |
console.warn("QA: <A> tag with external HREF "+$(this).attr("href")+" has no TARGET attribute"); | |
} | |
}); | |
$("img").each(function(){ | |
if( $(this).attr("alt") === undefined || $(this).attr("alt") === "" ) { | |
console.warn("QA: <IMG> tag with SRC \"" + $(this).attr("src") + "\" has no ALT attribute"); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment