Recently, I created a basic jQuery script that stores values such as "voted1", "voted2", and "voted3" in localStorage. However, I encountered an issue where all values are stored simultaneously on click, whereas I require them to be stored individually per click for future jQuery operations (for example, initiating jQuery logic if "value3" is present).
Despite weeks of experimentation, I have been unable to resolve this dilemma.
Below is the HTML:
[gallery link="none" size="medium" ids="102,13,27,25,23,15" orderby="rand"]
<div class="exists" style="display: none;">Thank you for voting!</div>
CSS:
.gallery-item a {
// CSS styles here
}
.exists {
// Additional CSS styles here
}
.voted {
// More CSS styles here
}
And here's the jQuery code snippet:
$(document).ready(function() {
var voteLink = $('.gallery-item a');
var votedYes = $('.exists');
voteLink.one('click', function() {
// jQuery action on click
})
});
Does anyone have any insights into how I can save these values separately in localStorage on each click?
Thanks a lot!