view raw
KC Here KC Here - 11 months ago 47
Javascript Question

How to make my upvote/downvote button store cookies and count votes only 1 time

Take a look at this I made this upvote/downvote button for my website, but it resets every time I refresh the website + it counts votes every time I click on it. I have no idea how to fix it since I am a bit new. Can someone make a javascript suggestion for me or give me a website link where I can learn it? I spent 3-4 days in searching it without success.


You can learn HTML5 Web Storage, and use them with the following code.

$(document).ready(function() {
    if(localStorage.getItem("count") == null)

var counter = 0;
  localStorage.setItem("count", counter);

  localStorage.setItem("count", counter);