Creating a like button that shows how many likes it has [from real people]

  html, javascript

Creating a social media, how do i create a like button?

Heres the code i tried to use:

<!-- Add icon library -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

<!-- Use an element to toggle between a like/dislike icon -->
<i onclick="myFunction(this)" class="fa fa-thumbs-up"></i>

The Like Button Script

<i class="mdi-action-favorite red-text text-lighten-1"></i> <a href="#" onclick="AddValue()">0</a>

<script>
var startingNumber = 0;

function AddValue()
{
   startingNumber++;
   $(this).text(startingNumber);
}

</script>

When i tried it, it didn’t work properly. the number of likes dosent increase by 1.

Source: Ask Javascript Questions

LEAVE A COMMENT