Search code examples
javascriptjqueryhtmlcustom-data-attributevoting-system

Clientside Heart Vote


Is there a way to implement a simple Heart vote(just +1 vote with counter without ability to vote more than once) using only Javascript / jQuery and HTML5 data attributes, other HTML5 APIs, without any serverside stuff?


Solution

  • You can use localStorage to record that client has voted. Something like this:

    localStorage.setItem('voted', true);
    

    To check if client voted before:

    var voted = localStorage.get item('voted');
    

    Update:

    As you need a counter, you may try one of BAAS (backend-as-a-service) services, such as parse.com or kinvey.com