JSFiddle - React, Tailwind, and code Playground
HTML
<div id="bodyarea">
<div class="share_fb">Share on facebook</div>
</div>
JavaScript
$("#bodyarea").on('click', '.share_fb', function(event) {
event.preventDefault();
var that = $(this);
var post = that.parents('article.post-area');
$.ajaxSetup({ cache: true });
$.getScript('//connect.facebook.net/en_US/sdk.js', function(){
FB.init({
appId: '822306031169238',
version: 'v2.3' // or v2.0, v2.1, v2.0
});
FB.ui({
method: 'share',
title: 'Title Goes here',
description: 'Description Goes here. Description Goes here. Description Goes here. Description Goes here. Description Goes here. ',
href: 'https://developers.facebook.com/docs/',
},
function(response) {
if (response && !response.error_code) {
alert('Posting completed.');
} else {
alert('Error while posting.');
}
});
});
});