是否可以在点击链接时创建推特按钮? :
http://fiddle.jshell.net/gmq39/22/
我尝试过:
$.getScript('http://platform.twitter.com/widgets.js');
“按钮”,看起来没有任何功能和风格
任何人都知道一个解决方法或我需要做什么?需要你的帮助..问候!!
答案 0 :(得分:1)
使用twttr.widgets.load();
将Twitter功能绑定到动态添加的按钮。
另外,为了确保您不会反复加载脚本,您可以先检查脚本是否已经加载了类似的内容
function twitter() {
if ($(".twitter-follow-button").length > 0) {
if (typeof (twttr) != 'undefined') {
twttr.widgets.load();
} else {
$.getScript('http://platform.twitter.com/widgets.js');
}
}
}
$(function () {
$('body').html('<a href="https://twitter.com/MagnusEngdal" class="twitter-follow-button" data-show-count="false">Follow @MagnusEngdal</a>')
twitter();
});