When I do a click, I assign a disabled attribute
to the button:
$(".save_post").on("click", function() {
$(this).attr("disabled", "true");
});
However, if I change page and then I go back to this one, the button should keep the disabled attribute given, this is fine if I use localStorage:
localStorage.setItem("savedArticle", "savedButton");
var myButtonState = localStorage.getItem("savedArticle", "savedButton");
$(".save_post").addClass(myButtonState);
However, I have different pages which can have <button type="button" class="save_post">SAVE</button>
so each time I click on a button, a disabled attribute
is given, but if I use the localStorage
like above, it will add myButtonState
to all buttons with class .save_post
each time we land on a page with it.
I am trying to add the attribute only to the buttons really clicked.