This page is outdated
You are reading documentation for Linkify v2. Browse the latest v3+ documentation.
Jump To
Linkify DOM Element Interface
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
.
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 linkifyObject
[options
] Options objectHTMLDocument
[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