I’m using the following button from Twitter to tweet something.
<a id="tweet" href="https://twitter.com/share" class="twitter-share-button" data-text="Husam" data-size="large" data-count="none">Tweet it!</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');
</script>
In my JS file, I’m trying to change data-text attribute using jQuery attr function, so that it tweets what I would like to tweet.
$("#tweet").attr("data-text","what I want to tweet");
It just doesn’t work as expected, I can’t change the data-text attribute. Any ideas?
You can see the code here: http://codepen.io/husamp/pen/YyKLze