javascript - Tweet Share URL inflation Not Working inside button click function -


i working o quote app, jquery getjson inflate elementes. i'm having trouble integrating twitter's share button code. reason cannot pick text values api source when use attr function change tweet url data-text value.when click tweet button got new tweet window hardcoded text. intention set quote + author in text field. ideas make work? did lot of research , experimentation tweet event binds no success

my html code:

<html class="no-js" lang="">     <head>         <meta charset="utf-8">         <meta http-equiv="x-ua-compatible" content="ie=edge,chrome=1">         <title></title>         <meta name="description" content="">         <meta name="viewport" content="width=device-width, initial-scale=1">          <link rel="stylesheet" href="css/bootstrap.min.css">         <style>             body {                 padding-top: 50px;                 padding-bottom: 20px;             }         </style>         <link rel="stylesheet" href="css/bootstrap-theme.min.css">         <link rel="stylesheet" href="css/main.css">          <!--[if lt ie 9]>             <script src="js/vendor/html5-3.6-respond-1.4.2.min.js"></script>         <![endif]-->     </head>     <body>      <div id="btn-container" class="container">       <p><a id="btn1" class="btn btn-primary btn-lg" href="#" role="button">quote me</a></p>     </div>      <div id="quote-container" class="container">         <blockquote id="quote">never can hire else do, if can better.         </blockquote>         <footer id="author">bill bernback</footer>     </div>      <div id="share-container" class="container">         <a href="https://twitter.com/share" class="twitter-share-button" data-text="something other page title">tweet it</a>     </div>       <script async src="http://platform.twitter.com/widgets.js" charset="utf-8"></script>     <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>     <script>window.jquery || document.write('<script src="js/vendor/jquery-1.11.2.min.js"><\/script>')</script>     <script src="js/vendor/bootstrap.min.js"></script>     <script src="js/main.js"></script>     </body> </html> 

my js code:

<pre><code>var quote; var author  $(document).ready(function(){   $(".btn").click(function(){     $.getjson("http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&_jsonp=?", function(getquote) {       quote = getquote[0].content;       author = getquote[0].title;        $("#quote").html(quote);       $("#author").text(author);        $('.twitter-share-button').attr('data-text',author); // not working      });});}); 


Comments