【发布时间】:2014-01-05 19:44:23
【问题描述】:
这是我的 javascript:
if(!localStorage.status) localStorage['status'] = 1;
toggle(2);
enable.onclick = function(){toggle(0)};
disable.onclick = function(){toggle(1)};
function toggle(n){
/// code here not relevant to this question
}
}
这是我的html:
<form name="thename">
<input type="checkbox" name="option1"> Toggle it
</form>
现在如何将 javascript 连接到 html,以便选中该框切换值为 0,取消选中该框切换值为 1?
澄清:
需要为 0 或 1 的值是 'status' 的本地存储值。这就是我们要切换的值。
【问题讨论】:
-
您想要一个按钮启用,一个按钮禁用,还是一个按钮同时执行?
标签: javascript html button toggle local-storage