
$(document).ready(function(){
//demo1:
   //-隔行,滑动,点击 变色
 $('.cssraindemo1 tbody tr:even').addClass('odd');
 $('.cssraindemo1 tbody tr').hover(
  function() {$(this).addClass('highlight');},
  function() {$(this).removeClass('highlight');}
 );
 $('.cssraindemo1 tbody tr').click(
  function() {$(this).toggleClass('selected');}
 );

//demo2:
 $('.cssraindemo2 tbody tr:even').addClass('odd');
 $('.cssraindemo2 tbody tr').hover(
  function() {$(this).addClass('highlight');},
  function() {$(this).removeClass('highlight');}
 );

     // 如果复选框默认情况下是选择的，变色.
 $('.cssraindemo2 input[type="checkbox"]:checked').parents('tr').addClass('selected');
 // 复选框
 $('.cssraindemo2 tbody tr').click(
  function() {
   if ($(this).hasClass('selected')) {
    $(this).removeClass('selected');
    $(this).find('input[type="checkbox"]').removeAttr('checked');
   } else {
    $(this).addClass('selected');
    $(this).find('input[type="checkbox"]').attr('checked','checked');
   }
  }
 );

//demo3:
 $('.cssraindemo3 tbody tr:even').addClass('odd');
 $('.cssraindemo3 tbody tr').hover(
  function() {$(this).addClass('highlight');},
  function() {$(this).removeClass('highlight');}
 );

 // 如果单选框默认情况下是选择的，变色.
 $('.cssraindemo3 input[type="radio"]:checked').parents('tr').addClass('selected');
 
 // 单选框
 $('.cssraindemo3 tbody tr').click(
  function() {
   $(this).siblings().removeClass('selected');
   $(this).addClass('selected');
   $(this).find('input[type="radio"]').attr('checked','checked');
  }
 );
});
