直接上代码。
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head runat ="server" >
< title > Index </ title >
< script src ="/Scripts/jquery-1.4.1.js" type ="text/javascript" ></ script > < script type ="text/javascript" >
$( function () {
$( " #CheckAll " ).click( function () {
var flag = $( this ).attr( " checked " );
$( " [name=subBox]:checkbox " ).each( function () {
$( this ).attr( " checked " , flag);
})
})
})
</ script >
</ head >
< body >
< div >
< input id ="CheckAll" type ="checkbox" />
< input name ="subBox" type ="checkbox" />
< input name ="subBox" type ="checkbox" />
< input name ="subBox" type ="checkbox" />
< input name ="subBox" type ="checkbox" />
</ div >
</ body >
</ html >