Last active
September 12, 2016 18:59
-
-
Save apbassi89/e4bce1527f468e71093af2aecfabd576 to your computer and use it in GitHub Desktop.
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
| /** | |
| * Performs a "mini" heading audit of a webpage. | |
| * The page must have jQuery loaded in order for this script to work | |
| */ | |
| function auditHeadings() { | |
| var headings = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']; | |
| console.log("===== STARTING HEADING AUDIT =====") | |
| jQuery.each(headings, function (key, selector) { | |
| var headingsEl = jQuery(selector); | |
| if (!headingsEl.length) { | |
| console.log(">>> You don't have any <" + selector + "> tags on this page!"); | |
| } else { | |
| console.log(">>> You have " + headingsEl.length + " <" + selector + "> tags on this page!"); | |
| headingsEl.each(function (key, el) { | |
| console.log( | |
| el, | |
| jQuery.trim(jQuery(el).text().replace(/\s\s+/g, ' ')) | |
| ); | |
| }); | |
| } | |
| }); | |
| }; | |
| auditHeadings(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment