JSFiddle - React, Tailwind, and code Playground
HTML
<div id="fb-root"></div>
<div id="test">CLICK HERE</div>
<fb:like id="fbtest" href="http://www.test.com" send="true" width="450" show_faces="true"></fb:like>
JavaScript
// FACEBOOK INITIALISATION
window.fbAsyncInit = function() {
FB.init({ appId: '164880230301446',
status: true,
cookie: true,
xfbml: true
});
console.log('come on bro');
};
var e = document.createElement('script');
e.type = 'text/javascript';
e.async = true;
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
document.getElementsByTagName('body')[0].appendChild(e);
// ------------------------
(function ($) {
$.fn.reloadFacebookLike = function(url) {
$('#fbtest').attr('href', url).empty().off().removeData();
FB.XFBML.parse();
};
$(document).ready(function() {
$(document).on('click', '#test', function () {
$('#fbtest').reloadFacebookLike('http://www.test2.com');
});
});
}(jQuery));