Configuring the Facebook Like and Share buttons

In this section, we will learn how to integrate the Facebook Like button into our product pages. Facebook provides the markup and attributes to create a Like and Share button. The following HTML syntax shows the required markup for these buttons:

<div class="fb-like"
     data-href="${url}"
     data-layout="button_count"
     data-action="like"
     data-show-faces="true"
     data-share="true">
</div>

The attributes used in the markup are explained as follows:

  • data-href: This attribute has the value for the targeted link for the Like button.
  • data-layout: This attribute has the value for the style of the button.
  • data-action: This attribute has the value for the action to be done when a user clicks on the Like button.
  • data-show-faces ...

Get Developing Responsive Web Applications with AJAX and jQuery now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.