Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在localstorage javascript中保存更改文本按钮_Javascript_Html - Fatal编程技术网

如何在localstorage javascript中保存更改文本按钮

如何在localstorage javascript中保存更改文本按钮,javascript,html,Javascript,Html,我有10个按钮点击更改文本,不保存更改 我不止一次地提出这个问题,但我没有找到解决办法 var-activeButton=localStorage.getItem(“activeButton”); var isActive=localStorage.getItem(“isActive”); const allButtons=document.queryselectoral(“.button”); […所有按钮].forEach(函数(此按钮){ 如果(isActive==“true”){ 如果

我有10个按钮点击更改文本,不保存更改 我不止一次地提出这个问题,但我没有找到解决办法

var-activeButton=localStorage.getItem(“activeButton”);
var isActive=localStorage.getItem(“isActive”);
const allButtons=document.queryselectoral(“.button”);
[…所有按钮].forEach(函数(此按钮){
如果(isActive==“true”){
如果(activeButton!==thisButton.id){
thisButton.disabled=true;
}
}
});
const movetool=(事件)=>{
activeButton=localStorage.getItem(“activeButton”);
const target=event.target.closest(“按钮”);
如果(activeButton==target.id){
var enablell=false;
让saveuser=localStorage.getItem(“save_unsave”);
target.innerHTML=localStorage.setItem(“保存”、“未保存”、“已单击”);
数组.from(所有按钮).forEach(函数(此按钮){
如果(此按钮已禁用){
enablell=true;
返回;
}
});
如果(启用全部){
数组.from(所有按钮).forEach(函数(此按钮){
thisButton.disabled=false;
target.innerHTML=“单击”;
thisButton.innerHTML=“单击”;
});
setItem(“isActive”,false);
}否则{
数组.from(所有按钮).forEach(函数(此按钮){
thisButton.disabled=true;
thisButton.innerHTML=“不点击”;
setItem(“保存”、“未保存”、“单击”);
target.innerHTML=localStorage.getItem(“save_unsave”);
});
if(target.classList.contains(“按钮”)){
target.disabled=false;
setItem(“isActive”,true);
setItem(“activeButton”,target.id);
}
}
}否则{
数组.from(所有按钮).forEach(函数(此按钮){
thisButton.disabled=true;
thisButton.innerHTML=“不点击”;
setItem(“保存”、“未保存”、“单击”);
target.innerHTML=localStorage.getItem(“save_unsave”);
});
}
};

单击1
点击2
点击3
点击4

是的,我只是想减少字符数。我知道你最近已经问了几个类似的问题。不要那样做。相反,编辑现有问题。我知道,但我没有找到答案,你有答案吗?