I currently have a calculator, which generates output. I'm currently trying to generate a dynamic twitter button along with the output. I've made several attempts to get the twitter button to work, but it either shows up as a text link or doesn't show up at all. The code below is what I've used.
Method 1
$.getScript("http://platform.twitter.com/widgets.js");
var twit_link = $('<a/>', {
href : 'https://www.twitter.com/share',
'class' : 'twitter-share-button',
url : 'http://www.twitter.com/obamamakes',
'data-count' : 'none',
'data-via' : 'ObamaMakes',
'data-text' : 'In the time it takes me to ' + activity + ', Barack Obama makes $' + i.toFixed(1)
}).text('Tweet');
$("#CalcOutput").html( twit_link );
Method 2
$("#CalcOutput-twitter").html("<a href=\"https://twitter.com/intent/tweet?source=webclient&text=\"" + encodeURIComponent(result) + "\" class=\"twitter-share-button-activity\" url=\"http://www.twitter.com/obamamakes\" data-count=\"none\" data-via=\"ObamaMakes\" data-text=\"In the time it takes me to " + activity + ", Barack Obama makes $" + i.toFixed(1) + "> <img src=\"IMAGES/twitter.jpg\" id=\"imgTweet\" alt=\"Tweet This\" width=\"50px\" height=\"30px\"></a>");
Method 3
$("#CalcOutput-twitter").html("<a href=\"https://twitter.com/intent/tweet?source=webclient&text=\"" + encodeURIComponent(result) + "\" ><img src=\"IMAGES/twitter.jpg\" id=\"imgTweet\" alt=\"Tweet This\" width=\"50px\" height=\"30px\"></a>");