我在尝试使用 JavaScript 创建动态 Twitter 按钮时遇到问题。我试图让 twitter 按钮来推特我正在编程的计算器的输出。问题是按钮不会显示。我究竟做错了什么?请帮忙。
var twit_link = document.createElement('a');
twit_link.setAttribute('href', 'https://www.twitter.com/share');
twit_link.setAttribute('class', 'twitter-share-button');
twit_link.setAttribute('url', 'http://www.twitter.com/obamamakes';
twit_link.setAttribute('data-count', 'none');
twit_link.setAttribute('data-via', 'ObamaMakes');
twit_link.setAttribute('data-text', 'In the time it takes me to ' + activity + ', Barack Obama makes $' + i.toFixed(1);
twit_link.innerHTML = "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>");
$("#CalcOutput").append(twit_link);
我做了大家建议的更改,但是计算器应该产生的整个输出仍然没有与 twitter 按钮一起显示。我也应该提供计算器代码吗?