Skip to content

Instantly share code, notes, and snippets.



Last active Oct 6, 2015
What would you like to do?
Find any element Javascript
// Put in the element you want to find.
var el = document.getElementsByTagName("a"),
// Enter your search term
st = 'whatever',
// Results will go here when done
for(var i = 0; i < el.length; i++) {
// Checking to see if the returned element's innerText matches the search term
if(el[i].innerText === st) {
// Results have been saved if anything was found. You can now use the variable res to do whatever you'd like
res = el[i];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.