Snippets

Bluleadz Tweet This Snippet

Created by Chad Pierce last modified
<span class="twit">CONTENT TO BE TWEETED HERE</span>
 $('.twit').each(function(i, el) {

     // grab the url and the link text
     var twitterUser = '@CMTCSolutions',
         url = 'https://twitter.com/home?status=' + twitterUser + ' ',
         text = $(this).text(),
         shareText = text.replace(' ','%20');


     // empty a tag
     var newNode = $('<a class="twit"></a>').attr('href', url+shareText).attr('target', '_blank').html(text);

     // replace the current node with our new node
     $(el).replaceWith(newNode);


 });

$('body').on('click', 'a.twit', function(e){
    e.preventDefault();

    newwindow = window.open($(this).attr('href'),'','height=300,width=350');
    if (window.focus) {newwindow.focus()}
});

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.