Created
August 23, 2018 18:15
-
-
Save fmontes/48c2d07c2ceb3ab195224e69429b1e9c to your computer and use it in GitHub Desktop.
Find and replace text in a webpage
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
// Find all the existence of a text: | |
var headings = document.evaluate("//h4[contains(., 'String of text')]", document, null, XPathResult.ANY_TYPE, null ); | |
// Get one element | |
var el = headings.iterateNext(); | |
// Replace the text | |
el.innerText = 'New text' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment