Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
dynamically adapting the tweet button
<body>
The tweet button:
<span id='tweet-span'>
<a href="https://twitter.com/share" id='tweet'
class="twitter-share-button"
data-lang="en"
data-count='none'>Tweet</a>
<script>!function(d,s,id){varjs,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<script>
function tweetSetup() {
$(".twitter-share-button").remove();
var tweet = $('<a>')
.attr('href', "https://twitter.com/share")
.attr('id', "tweet")
.attr('class', "twitter-share-button")
.attr('data-lang', "en")
.attr('data-count', "none")
.text('Tweet');
$("#tweet-span").prepend(tweet);
tweet.attr('data-text', "#InfiniteJukebox of " + t.fixedTitle);
tweet.attr('data-url', document.URL);
twttr.widgets.load();
}
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment