已采納回答 / 奴奴雪人
這個要看你用什么開發平臺了,每個都不一樣的,sunlime text 的話,你可以取在默認建里面 ctrl + f 取查找 if關鍵字,可以去找,有些可能會出現快捷鍵 沖突,那就要改快捷鍵了。
2016-11-15
// 每個選項的事件
for(var i=0;i<inputs.length;i++){
inputs[i].onclick=function(){
showToatal()
}
}
for(var i=0;i<inputs.length;i++){
inputs[i].onclick=function(){
showToatal()
}
}
// 全選事件
all.onclick=function(){
for(var i=0;i<inputs.length;i++){
inputs[i].checked=this.checked
}
showToatal()
}
all.onclick=function(){
for(var i=0;i<inputs.length;i++){
inputs[i].checked=this.checked
}
showToatal()
}
// 計算已選項的總數
function showToatal(){
var tot=0;
for(var i=0;i<inputs.length;i++){
if(inputs[i].checked){
tot++
}
}
total.innerHTML='已選:' + tot + ' 項'
}
function showToatal(){
var tot=0;
for(var i=0;i<inputs.length;i++){
if(inputs[i].checked){
tot++
}
}
total.innerHTML='已選:' + tot + ' 項'
}
var ch = 0
for(var x=1;x<checkInputs.length-1;x++){
if(checkInputs[x].checked==true){
ch++;
}
}
if(ch==(checkInputs.length-checkAllInputs.length)){
for(var z=0;z<checkAllInputs.length;z++){
checkAllInputs[z].checked = true;
}
}
for(var x=1;x<checkInputs.length-1;x++){
if(checkInputs[x].checked==true){
ch++;
}
}
if(ch==(checkInputs.length-checkAllInputs.length)){
for(var z=0;z<checkAllInputs.length;z++){
checkAllInputs[z].checked = true;
}
}
2016-10-30