【发布时间】:2015-07-18 00:44:29
【问题描述】:
复选框状态值存储在 localStorage 中。 'updateStorage' 在 localStorage 中将这些键值对设置为 'null'。
只有在页面重新加载后才能看到效果。如何实现在函数调用后,将复选框状态更改为直接显示,例如在toggle中?
d3.select("#update").on("click",updateStorage);
function updateStorage(){
var updatethis = d3.selectAll(".box").each(function(){
var use_it = this.id;
localStorage.setItem(use_it,null);
d3.select(this).property('checked', null); //does not change display directly
});
};
添加这一行没有帮助
d3.select(this).property('checked', null);
我需要过渡吗??
【问题讨论】:
-
你尝试过使用
change事件来触发你的函数吗? -
这是一个按钮,用于将页面上的所有复选框重置为未选中;已尝试更改并单击该按钮。 localStorage 操作工作正常。所有复选框都设置为空,但除非页面重新加载,否则显示不会改变。
-
我的代码看起来很合乎逻辑,但我也想直观地切换复选框。
标签: javascript checkbox d3.js