写了个demo,有四个checkbox,点击查看按钮后alert出被选中的按钮,然后怎么才能让checkbox恢复未选中状态呢?
html代码:
1
2
3
4
script代码:
function checkbox()
{
var box1 = document.getElementById("checkbox1");
var box2 = document.getElementById("checkbox2");
var box3 = document.getElementById("checkbox3");
var box4 = document.getElementById("checkbox4");
if (box1.checked) {
alert(box1.value);
}
if (box2.checked) {
alert(box2.value);
}
if (box3.checked) {
alert(box3.value);
}
if (box4.checked) {
alert(box4.value);
}
//点击确认按钮后(或者点击下一页后)让所有按钮恢复初始状态
}
页面状态:
由于使用了bootstrap,点击按钮后,实际改变的是当前div的class:
咱们才能把选中的按钮变为未选中的状态呢?