Javascript全选反选函数

Js函数部分..

//2011-04-28
//by hkshadow
function CheckAll(s,b){
	var a = document.getElementById(s).getElementsByTagName("input");
	var selall=document.getElementById(b).checked;
	for (var i=0; i<a.length; i++)
	   if(selall==true){
       		for (var i=0; i<a.length; i++)
	   				if (a[i].type == "checkbox") a[i].checked = true;
			 }else{ 		
  				for (var i=0; i<a.length; i++)	
       			if (a[i].type == "checkbox") a[i].checked = false ;
			}
	}

HTML演示部分..

Read more