unmark() method

Syntax

// javascript
const instance = new Mark(context);
instance.unmark([options]);
// jQuery
$(context).unmark([options]);

Parameters:

  • options object - Optional options:

OptionTypeDefaultDescription
elementstring markSpecifies marked elements to remove.

Important: if other than default marked element is used, e.g. span, it must be also specified in the unmark() method. It is also possible to use * in case of using different marked elements to unmark in one run. A mark.js library uses a default selector *[data-markjs] but it is not safe to apply to all HTML elements.

classNamestring ''Remove only marked elements with specified class name.
excludestring or string[] []A string or an array of selectors. Specifies DOM elements that should be excluded from searching.
shadowDOMboolean undefinedWhether to remove marked elements inside shadow DOMs

Note: if the shadowDOM option is used with highlighting method, it must be also specified in the unmark() method.
See Highlighting in shadow DOM for more details.

iframesboolean falseWhether to search inside iframes

Note: if the iframes option is used with highlighting method, it must be also specified in the unmark() method.

iframesTimeoutnumber 5000 msThe max time to wait for iframe(s) to load before skipping
debugboolean falseWhether to log messages
logobject consoleLog messages to a specific object
donefunction A callback after all specified marked elements were removed
done : () => {}

It has no parameters.

Example with default options values
const options = {
    element : 'mark',
    className : '',
    shadowDOM : false,
    iframes : false,
    iframesTimeout : 5000,
    done : () => {},
    debug : false,
    log : window.console
};

JavaScript:

var instance = new Mark(document.querySelector('selector'));
instance.unmark(options);

jQuery:

$('selector').unmark(options);