I have a slider and I want to be able to set the value into local storage so that I can use this value dynamically on a web page.
The part I need help with is chrome.storage.local.set(v);
.
$('#slider').on('change', function () {
var v = $(this).val();
$( 'div').each(function () {
this.style.setProperty( 'margin', '10px '+v+'px', 'important' );
});
chrome.storage.local.set(v);
});
The variable works perfectly, I just need to be able to save it into localstorage so I can use it. It works before page reload, so all I need now is to be able to put it into storage so on reloading that page it saves the value.
update: is this what you were saying to do?
$('#slider').on('change', function () {
var v = $(this).val();
var theKeyForV = chrome.storage.local.get({"keyforv" : v},
chrome.storage.local.set({"keyforv" : v},
function(){
// callback (what goes here?)
});
$( 'div').each(function () {
this.style.setProperty( 'margin', '10px '+theKeyForV+'px', 'important' );
});
});