Skip to content

Instantly share code, notes, and snippets.

@alpgul
Created June 8, 2019 06:07
Show Gist options
  • Save alpgul/9773e17902b2b7348d9f65b07df56856 to your computer and use it in GitHub Desktop.
Save alpgul/9773e17902b2b7348d9f65b07df56856 to your computer and use it in GitHub Desktop.
How to select all tags with specific text content in Javascript?
function contains(selector, text) {
var elements = document.querySelectorAll(selector);
return Array.prototype.filter.call(elements, function(element){
return RegExp(text).test(element.textContent);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment