Linkify 2.1 released! ×

linkify-element is an interface for replacing links within native DOM elements with anchor tags. Note that linkify-element is included with linkify-jquery, so you do not have to install it if you are using linkify-jquery.

Jump to

Installation

Node.js/Browserify

npm install linkifyjs
var linkifyElement = require('linkifyjs/element');

or with ES6 modules

import linkifyElement from 'linkifyjs/element';

AMD

<script src="linkify.amd.js"></script>
<script src="linkify-element.amd.js"></script>
<script>
    require(['linkify-element'], function (linkifyElement) {
        // …
    });
</script>

Browser globals

<script src="linkify.js"></script>
<script src="linkify-element.js"></script>

Usage

var options = {/* … */};
linkifyElement(document.getElementById('id'), options, document);

This recursively finds links in text nodes within element #id.

Params

  • HTMLElement element DOM Element to linkify
  • Object [options] Options object
  • HTMLDocument [doc] Explicitly pass in the document object or document implementation if on a non-browser environment like Node.js

Returns HTMLElement element The same element provided as input