Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
jQuery Click to Tweet - written for Blogger but can be modified for other platforms. In use: add the class "tweetable" to the element you'd like to make into a tweetable sentence.
<script src="//"></script>
<script type='text/javascript'>
$(document).ready(function() {
$('.tweetable').each(function() {
var sentence = $(this);
var permalink = sentence.parents('.post-outer').find('.timestamp-link').attr('href') || $(location).attr('href');
var tweetable = sentence.text();
var result = encodeURIComponent(tweetable);
var link = encodeURIComponent(permalink);
sentence.wrap('<a class="tweet-link" href="' + result + " " + link +'"></a>');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment