Submit your widget

A jQuery Plugin which lets you Share what you selected

Created 10 years ago   Views 5281   downloads 956    Author n/a
A jQuery Plugin which lets you Share what you selected
View DemoDownload
Share |

ContentShare is a jQuery plugin which lets you share the exact content on a page which you actually want to share. It enables you to share selected text on your social network rather the default text specified in the <meta> tags. By default, it supports Facebook and Twitter but you can add more networks easily.

Getting Started

Four files are required for this plugin to work but not even a single line of code, just include them within the <head> tag and you are done!

     // css file for tooltip
     <link rel="stylesheet" type="text/css" href="tooltipster.min.css"/>
     // jquery library
     <script src="jquery-1.8.3.min.js"></script>
     // tooltip plugin
     <script type="text/javascript" src="jquery.tooltipster.min.js"></script>
     // our awesome ContentShare plugin
     <script src="contentshare.js"></script>


ContentShare by default works on the text within <p> tags. So, if you are okay with this then you can skip this part.

To customize, you can specify any element via CSS/jQuery Selectors and pass it while calling the plugin like:

// calling the plugin on DOM ready

NOTE: The above code can be found at the end of contentshare.js file. You can do your modifications in the highlighted line (Line No.3)


Variable Description Default Value Valid Values
Array of Links to the Icons which appear in the Tooltip ["img/fb.png","img/tw.png"] Array of Links, the links can be absolute or relative
Array of Share Links belonging to different Social Networks See Facebook's Sharer or Feed Dialog and Twitter's Intent See Facebook's Sharer or Feed Dialog and Twitter's Intent
Minimum number of characters to be selected for this plugin to work 5 Any Number
Clicking on any one of the social links opens in a new tab true Either trueor false
The name of the class which is used by the plugin contentshare Any String which obeys W3 Standards for class names


Here are some tips to elegantly play with the plugin →

1) You can change the colour of the selected text by adding a simple CSS Rule for <mark> tag like:


2) You can even add more social networks or replace the existing ones by defining your own default settings as:

$.fn.contentshare.defaults = {
    shareIcons : ["img/icon1.png" , "img/icon2.png"],
    shareLinks  : ["" , ""]

3) This plugin uses Tooltipster Plugin for tooltips so for styling the tooltip you can refer the doc for Tooltipster