Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/angezid/advanced-mark.js/llms.txt

Use this file to discover all available pages before exploring further.

unmark() removes all mark elements created by advanced-mark.js and normalizes text nodes back to their original state. When using the CSS Custom Highlight API, it removes the registered StaticRange/Range objects from the HighlightRegistry instead of modifying the DOM. Use unmark() before calling mark() again to avoid stacking highlights on top of previous ones.

Syntax

// Vanilla JS
const instance = new Mark(context);
instance.unmark([options]);

// jQuery
$(selector).unmark([options]);

Parameters

options
object
Optional configuration object. All properties are optional.

Default Options

const options = {
  highlight: undefined,
  highlightName: 'advanced-markjs',
  element: 'mark',
  className: '',
  exclude: [],
  shadowDOM: false,
  iframes: false,
  iframesTimeout: 5000,
  done: () => {},
  debug: false,
  log: window.console,
};

Usage Examples

const instance = new Mark(document.querySelector('.content'));

// Remove all default <mark> elements
instance.unmark();
When the highlight option is provided, unmark() only removes ranges from the HighlightRegistry — it does not unwrap any DOM elements. Use this when you are exclusively using the CSS Custom Highlight API and want to avoid an unnecessary DOM traversal.
To unmark elements that were marked with a custom tag (e.g. element: 'span'), you must pass the same tag name to unmark(). Alternatively, pass element: '*' to remove any element carrying the data-markjs attribute, regardless of tag name. Note that using '*' applies broadly — only use it when you are certain all data-markjs elements in the context should be removed.

Build docs developers (and LLMs) love