default usage:
const thl = new TextHighlight(document.body, 'lorem');
with options, and custom search element
const options = {
autoinit: true,
search: 'met',
max: null, // max elements to highlight
minInput: 2, // min input to trigger highlight
maxInput: null, // max input to trigger highlight
caseSensitive: false,
fullwordonly: false, // mark only if the full word is given
markwholeWord: true, // mark the whole word (if a part is selected)
className: 'highlight2', // to style the highlight word
highlightSection: false, // ad a class to the wrapping html element
sectionClassName: 'section-highlight', // class name for the wrapping element
};
// only search within this element (#myElement)
const myElement = document.querySelector('#myElement', options);
const thl = new TextHighlight(myElement, options);
Eum neque, ipsa tempore ex iusto non inventore numquam magnam ut. Eos optio assumenda ullam vitae, iure doloremque exercitationem. Minus accusamus sint vel eos adipisci culpa architecto animi id eaque mollitia enim amet quasi deleniti, ipsa tempora commodi laudantium at ab minima aperiam repellat. Unde, odio quisquam explicabo aliquam, quia a cupiditate at nulla, eaque magni provident!
Sit amet consectetur adipisicing elit. Repellendus, et. Voluptate dolorem incidunt voluptatem minima rem dolore molestias suscipit quasi.
Quam dolor voluptatem fugiat facere. Maiores numquam corporis sint in nisi qui, vero eos quod nobis minima sunt accusantium expedita repellat error similique maxime, dolorem saepe ipsa dolor. Mollitia, reprehenderit at voluptate enim saepe accusamus minima porro ea odio laboriosam magnam sapiente sit exercitationem, natus.
type here: