i need to store few element in temp variable, so when i get back to that pahe i can show them on page load
i have about 8 li element but let's i click on 5 li, so i want to store 5 li id somewhere
$("#divPopup").on("click", "li", function () {
...
var newId = $this.attr('Id').replace("Left", "Right")
// here i want to store newID, each time user click on event, it should be unique values , i want to store in $('#hdnValueProjectBtn').val(newId);
}
else {
var newId = $this.attr('Id').replace("Left", "Right")
$('#' + newId).hide();
}
});
You can use localStorage in supported browsers and fallback to Cookies in older ones, here is an example:
// store value
if (window.localStorage !== undefined) {
window.localStorage.setItem("li_id", id);
} else {
// WARNING: the following will overwrite current document cookie.
document.cookie = ["li_id", "=", id, "; domain=.", window.location.host, "; path=" + window.location.pathname + ";"].join("");
}
// get value
var savedValue;
if (window.localStorage !== undefined) {
savedValue = window.localStorage.getItem("li_id");
} else {
savedValue = document.cookie.split(";")[0].split("=")[1];
}
alert(savedValue);
Note that id in snippet above is the value you want to store.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With