Created
September 23, 2017 20:15
-
-
Save clayrisser/039988e73eb303913fdf7aef2300aff1 to your computer and use it in GitHub Desktop.
Get h2 tag content
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
var h2Tags = document.getElementsByTagName('h2'); | |
var h2Inner = []; | |
for (var i = 0; i < h2Tags.length; i++) { | |
var h2Tag = h2Tags[i]; | |
if (h2Tag.getElementsByTagName('a').length > 0) { | |
h2Inner.push(h2Tag.getElementsByTagName('a')[0].innerHTML); | |
} else { | |
h2Inner.push(h2Tag.innerHTML); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment