Share Customize Text in Twitter using jQuery

  1. <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>  
  2. <script type="text/javascript">  
  3.     // We bind a new event to our link  
  4.     $('#click_button').live("click", function(e)  
  5.     {  
  6.         var twitter_text = $("#twitter_text").val();  
  7.         //We tell our browser not to follow that link  
  8.         e.preventDefault();  
  9.         //We get the URL of the link  
  10.         var loc = $(this).attr('href');  
  11.         //We get the title of the link  
  12.         var title = encodeURIComponent($(this).attr('title'));  
  13.         //We trigger a new window with the Twitter dialog, in the middle of the page  
  14.         window.open('http://twitter.com/share?url=' + loc + '&text=' + twitter_text + '&''twitterwindow''height=450, width=550, top=' + ($(window).height() / 2 - 225) + ', left=' + $(window).width() / 2 + ', toolbar=0, location=0, menubar=0, directories=0, scrollbars=0');  
  15.     });  
  16. </script> <textarea rows="4" cols="50" id="twitter_text">  
  17. At w3schools.com you will learn how to make a website.</textarea> <button type="button" id="click_button">Click Me!</button>