$(function(){ 
     
 $("#titlecheckbox").click(function () {  
     if( $("#titleCheckbox").attr("checked")==true){ 
  $("input[name='myCheckbox']").attr("checked", true); 
     }else{ 
  $("input[name='myCheckbox']").attr("checked", false); 
     } 
 });      
$("input[name='myCheckbox']").bind("click", function () { 
      
    var  check_flag=true; 
   $("input[name='myCheckbox']").each(function(){
 if($(this).attr("checked")==false){ 
    $("#titleCheckbox").attr("checked", false); 
    check_flag=false; 
    return false; //跳出each循环 
 } 
} );
if(check_flag){ 
   $("#titleCheckbox").attr("checked", true); 
}
});
});