I have a form set up to highlight matching text as you select checkboxes on the page. It works well when checking boxes, but if you uncheck one box out of many checked, all highlights disappear. I want it to only remove the highlight from the unchecked box that was changed.
As someone new to JavaScript, I'm unsure if I'm overlooking something obvious or not, but I can't figure out why this is happening.
Here's an example function that manages highlighting for a single checkbox. You can view my complete code on JS Fiddle at: https://jsfiddle.net/gosem01/kf8az926/1/
function highlightArrowsOnCheck() {
var instanceArrows = new Mark(highlightedParagraph);
var options = {
"debug": true,
"log": window.console
};
if (checkedArrows.checked) {
instanceArrows.markRegExp(/\«|»/g, options);
} else {
instanceArrows.unmark(options);
}
}
For more information on mark.js, visit the documentation here: