var quoteUrl = 'http://api.forismatic.com/api/1.0/?method=getQuote&format=jsonp&jsonp=parseQuote&lang=en';
$(document).ready(function() {
$(".btn").on('click',function() {
$.ajax({
url: quoteUrl,
crossDomain: true,
jsonpCallback: 'parseQuote',
dataType: 'jsonp',
success: function(data) {
$(".insertionPoint>.quote").html(data.quoteText);
$(".author").html("-" + data.quoteAuthor);
$(".twitter-share-button").attr('data-text',encodeURIComponent(data.quoteText));
console.log($(".twitter-share-button").attr('data-text'));
}
});
});
});
<a href="https://twitter.com/share" class="twitter-share-button" data-text="" data-count="vertical">
<i class="fa fa-twitter" aria-hidden="true"></i> </a>
<script type="text/javascript" async src="https://platform.twitter.com/widgets.js"></script>
Hi I’ve been using this code for share button. But I cannot seem to extract the text-area attributes value out of on click function.Codepen Link