jQuery Plugin To Transform URLs In Text Into Links - linkify

File Size: | 98.4 KB |
---|---|
Views Total: | 4770 |
Last Update: | |
Publish Date: | |
Official Website: | Go to website |
License: | MIT |
linkify is a JavaScript library which can be used to automatically transform valid URLs and email addresses in text into clickable links.
Supports node.js, browser, jQuery, Vanilla JavaScript, React.js, metions, hashtag, ticket, and much more.
See also:
Install & Download:
# Yarn $ yarn add linkifyjs # NPM $ npm install linkifyjs --save
Basic Usage:
1. Include jQuery library and the jQuery linkify plugin in the page.
<script src="jquery.min.js"></script> <script src="linkify.min.js"></script> <script src="linkify-jquery.min.js"></script>
2. To use plugins, include the plugin's JavaScript in the document. All possible plugins:
- hashtag: supports #hashtag
- mention: supports @mention
- ticket: supports Github-style tickets/issues
<script src="linkify-plugin-hashtag.amd.min.js"></script> <script src="linkify-plugin-mention.amd.js"></script> <script src="linkify-plugin-ticket.amd.js"></script>
3. Include a polyfill for legacy browsers.
<script src="linkify-polyfill.min.js"></script>
4. A Linkified object contains a DOM node (or just plain text) whose inner text is replaced by HTML containing <a>
links to URLs discovered in that text.
<p>My website is https://www.jqueryscript.net</p> <p>My email address is [email protected]</p>
5. Call the plugin and done.
$(function(){ $('p').linkify(); });
6. All default plugin settings.
$('p').linkify({ // additional attributes for the links attributes: null, // default CSS class className: 'linkified', // default protocol defaultProtocol: 'http', /* event listeners click: function (e) { alert('Link clicked!'); } */ events: null, // format the text format: function (value, type) { return value; }, // format the href formatHref: function (href, type) { return href; }, // ignore specified HTML tags ignoreTags: [], // if true, \n line breaks will automatically be converted to <br> tags. nl2br: false, // the tag that should be used to wrap each URL. This is useful for cases where a tags might be innapropriate, or might syntax problems tagName: 'a', // target attribute for each linkified tag. target: { url: '_blank' }, // custom validation rules here validate: true });
7. Find all links in the given string.
linkify.find('any string here');
Changelog:
v2.1.8 (2019-01-30)
- Allow mentions with inner @ sign for federated mentions
- Drop official support for Internet Explorer 8 and Node.js 6 (still supported unofficially but may break in future releases)
- Update dev dependencies
v2.1.7 (2018-03-06)
- update
v1.1.7 (2014-08-06)
- update
v1.1.6 (2014-05-15)
- update
v1.1.5 (2014-05-14)
- update
v1.1.4 (2014-04-10)
- Added option for detecting ports
v1.1.3 (2014-01-19)
- update to the latest version.
This awesome jQuery plugin is developed by SoapBox. For more Advanced Usages, please check the demo page or visit the official website.