Skip to content

Instantly share code, notes, and snippets.

@residualmind
Created August 11, 2013 12:05
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 residualmind/6204605 to your computer and use it in GitHub Desktop.
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
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