我正在尝试显示 twitter 按钮,但 twitter 按钮的代码显示为文本链接。我一直在尝试解决这个问题,但它不会变回按钮。我究竟做错了什么?请帮忙。
var i = 0;
var a;
var b;
var c;
var d;
function calculate() {
console.log(1);
var activity = $("#txtActivity").val();
var days = parseInt( $("#txtDays").val(), 10);
var hours = parseInt( $("#txtHours").val(), 10);
var minutes = parseInt( $("#txtMinutes").val(), 10);
var seconds = parseInt( $("#txtSeconds").val(), 10);
var MoneyMadeDuringActivity = (days * 21464) + (hours * 2683) + (minutes * 44.72) + (seconds * 0.74);
MoneyMadeDuringActivity = MoneyMadeDuringActivity.toFixed(2);
if (isNaN(MoneyMadeDuringActivity)) {
MoneyMadeDuringActivity = 0.00;
}
if (i < MoneyMadeDuringActivity) {
if (a < MoneyMadeDuringActivity) { i = i + a; }
if (b < MoneyMadeDuringActivity) { i = i + b; }
if (c < MoneyMadeDuringActivity) { i = i + c; }
if (d < MoneyMadeDuringActivity) { i = i + d; }
} else if (i > MoneyMadeDuringActivity) {
if (a < MoneyMadeDuringActivity) { i = i - a; }
if (b < MoneyMadeDuringActivity) { i = i - b; }
if (c < MoneyMadeDuringActivity) { i = i - c; }
if (d < MoneyMadeDuringActivity) { i = i - d; }
}
$.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("In the time it takes me to <span class=\"num\">" + activity + "</span>,<br /> Barack Obama makes <span class=\"num\">" + "$" + i.toFixed(1) + "</span><br />");
$("#CalcOutput").append( twit_link );
}
$("#txtDays").focus(function() {
$(this).val('');
});
$("#txtDays").keyup(function(event) {
a = 2683;
setInterval(calculate, 5);
});
$("#txtHours").focus(function(){
$(this).val('');
});
$("#txtHours").keyup(function(event) {
b = 670.75;
setInterval(calculate, 5);
});
$("#txtMinutes").focus(function() {
$(this).val('');
});
$("#txtMinutes").keyup(function(event) {
c = 22.36;
setInterval(calculate, 5);
});
$("#txtSeconds").focus(function(){
$(this).val('');
});
$("#txtSeconds").keyup(function(event) {
d = 0.37;
setInterval(calculate, 5);
});