We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I've added function to include a href and target when finding and replacing with an anchor link;
The script trips over itself. if I try and find and replace a match within a second previously compiled match;
i.e. Some and Some Body
findAndReplaceDOMText(document.getElementById('newsPage'), { find: 'Some', wrap: 'a', wrapClass: 'ClassOne', wrapTarget: '_blank', wrapLink: 'http://www.linkOne.com' });
findAndReplaceDOMText(document.getElementById('newsPage'), { find: 'Some Body', wrap: 'a', wrapClass: 'ClassTwo', wrapTarget: '_blank', wrapLink: 'http://www.linkTwo.com' });
Outputs
<a class="ClassOne" href="http://www.LinkOne.com" target="_blank"><a class="ClassTwo" href="http://www.LinkTwo.com" target="_blank">Some</a></a> <a class="ClassTwo" href="http://www.LinkTwo.com" target="_blank"> Body</a>
A more elegant solution would be be to have the replace on 'Some' not happen.
<a class="ClassOne" href="http://www.LinkOne.com" target="_blank">Some</a> <a class="ClassTwo" href="http://www.LinkTwo.com" target="_blank"> Body</a>
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I've added function to include a href and target when finding and replacing with an anchor link;
The script trips over itself. if I try and find and replace a match within a second previously compiled match;
i.e. Some
and
Some Body
findAndReplaceDOMText(document.getElementById('newsPage'), {
find: 'Some',
wrap: 'a',
wrapClass: 'ClassOne',
wrapTarget: '_blank',
wrapLink: 'http://www.linkOne.com'
});
findAndReplaceDOMText(document.getElementById('newsPage'), {
find: 'Some Body',
wrap: 'a',
wrapClass: 'ClassTwo',
wrapTarget: '_blank',
wrapLink: 'http://www.linkTwo.com'
});
Outputs
A more elegant solution would be be to have the replace on 'Some' not happen.
The text was updated successfully, but these errors were encountered: