Skip to content

BitLucid/jquery-linkify

This branch is up to date with uudashr/jquery-linkify:master.

Repository files navigation

Linkify jQuery Plugin

Linkify is jQuery plugin to formatting the text that contains URL or hashtag into a clickable HTML content.

It's small, it has no test suite but handles the large majority of cases, with exceptions (e.g. detecting modern TLDs like .museum properly, or punctuation at the end of the URL). For advanced options, check out the linkify or the urlize library.

Usage

Include the plugin script

<script src="jquery.linkify.js" type="text/javascript"></script>
$("#content").linkify();

or to enable the hashtag link

function toHashtagUrl(hashtag) {
  return "http://myservice.com?q=" + hashtag;
}

$("#content-with-hashtag").linkify(toHashtagUrl);

or if you want to disable the URL that does't include http

function toHashtagUrl(hashtag) {
  return "http://myservice.com?q=" + hashtag;
}

$("#content-with-hashtag").linkify({
	hashtagUrlBuilder: toHashtagUrl, 
	includeW3: false
});

or to specify the target for links

$("#content").linkify({
	target: "_blank"
});

About

jQuery plugin to enable clicking on URL and hashtag

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 67.2%
  • HTML 32.8%