Highlight text in DOM.
$ npm install text-highlighter --save
<div id="container">
We 💓 TypeScript!
</div>
<script src="lib/text-highlighter.js"></script>
<script>
var textHighlighter = new TextHighlighter(document.getElementById('container'));
// apply highlight
textHighlighter.highlight('typescript');
// remove highlight
textHighlighter.dehighlight();
</script>
before
<div id="container">
We 💓 TypeScript!
</div>
<script>
...
// apply highlight
textHighlighter.highlight('typescript');
</script>
after
<div id="container">
We 💓 <mark>TypeScript</mark>!
</div>
- http://stackoverflow.com/questions/10416643/highlight-words-in-html-using-regex-javascript-almost-there
- http://jquery.nj-clucker.com/change-double-byte-to-half-width/
MIT