I got a small code, that generates a Twitter-Button from a html element.
$('.article').append(function() {
var tweet = $(this).find('.tweet').html();
var twitterurl = 'https://twitter.com/home/?status=' + encodeURIComponent(tweet);
return "<a class='btn btn-primary' href='" + twitterurl + "'>Share on Twitter</a>";
});
It's working generally, but: somehow the original text gets encoded twice. I noticed that when a & character was decoded by twitter to &. I traced it back and found that my script generates a url including %26amp . That of course is decoded by twitter to &. Thanks for any help to solve this!