zoukankan      html  css  js  c++  java
  • 隔行,滑动,点击 变色.+ 多选框

    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>无标题文档</title>
    <style type="text/css">
    html,body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,form,fieldset,legend,input,select,button,textarea,p,table,tr,th,td,tfoot,thead { margin:0; padding:0; }
    body { font:12px/150% Arial,Helvetica,sans-serif; height:100%; background-color:#efefef; }
    html { height:100%; }
    table { border-collapse:collapse; border-spacing:0; }
      h3   { font:bold 15px/26px Arial;}  
        table  { border:0;border-collapse:collapse;}  
        td { font:normal 12px/17px Arial;padding:2px;100px;}  
        th   { font:bold 12px/17px Arial;text-align:left;padding:4px;border-bottom:1px solid #333;}  
        tr.odd  { background:#FFF3BF;}  
        tr.highlight { background:#6F4DFF;}  
        tr.selected  { background:#aaaaaa;color:#fff;}
    </style>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
     $(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');  //find 取得当前元素集合的每个元素的后代  
           }  
          }  
         );  
     
        //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');  
          }  
         );  
        });  
     
    })
    </script>
    </head>
    
    <body>
    
    
    
    
    
    
     <!-- demo1 -->  
        <h3>Demo1--隔行,滑动,点击 变色.</h3>  
        <table class="cssraindemo1">  
        <thead>  
        <tr>  
         <th>姓名</th>  
         <th>性别</th>  
         <th>暂住地</th>  
        </tr>  
        </thead>  
        <tbody>  
        <tr>  
          <td>张山</td>  
         <td>男</td>  
         <td>北京东城</td>  
        </tr>  
        <tr>  
         <td>李四</td>  
         <td>女</td>  
         <td>北京西城</td>  
        </tr>  
        <tr>  
         <td>王五</td>  
         <td>男</td>  
         <td>北京海淀</td>  
        </tr>  
        <tr>  
         <td>找六</td>  
         <td>男</td>  
         <td>北京朝阳</td>                              
        </tr>  
        <tr>  
         <td>孙七</td>  
         <td>男</td>  
         <td>北京昌平</td>  
        </tr>  
        </tbody>  
        </table>  
        <!-- demo2 -->  
        <h3>Demo2--隔行,滑动,点击 变色.+  多选框</h3>  
        <table class="cssraindemo2">  
        <thead>  
        <tr>  
         <th> </th>  
        <th>姓名</th>  
         <th>性别</th>  
         <th>暂住地</th>  
        </tr>  
        </thead>  
        <tbody>  
        <tr>  
         <td><input type="checkbox" name="tablechoice1" value="" /></td>  
           <td>张山</td>  
         <td>男</td>  
         <td>北京东城</td>  
        </tr>  
        <tr>  
         <td><input type="checkbox" name="tablechoice1" value="" /></td>  
           <td>李四</td>  
         <td>女</td>  
         <td>北京西城</td>  
        </tr>  
        <tr>  
         <td><input type="checkbox" name="tablechoice1" value="" checked/></td>  
            <td>王五</td>  
         <td>男</td>  
         <td>北京海淀</td>  
        </tr>  
        <tr>  
         <td><input type="checkbox" name="tablechoice1" value="" /></td>  
          <td>找六</td>  
         <td>男</td>  
         <td>北京朝阳</td>   
        </tr>  
        <tr>  
         <td><input type="checkbox" name="tablechoice1" value="" /></td>  
           <td>孙七</td>  
         <td>男</td>  
         <td>北京昌平</td>  
        </tr>  
        </tbody>  
        </table>  
     
        <!-- demo3 -->  
        <h3>Demo3--隔行,滑动,点击 变色+  单选框</h3>  
        <table class="cssraindemo3">  
        <thead>  
        <tr>  
         <th> </th>  
        <th>姓名</th>  
         <th>性别</th>  
         <th>暂住地</th>  
        </tr>  
        </thead>  
        <tbody>  
        <tr>  
         <td><input type="radio" name="tablechoice" value=""/></td>  
           <td>张山</td>  
         <td>男</td>  
         <td>北京东城</td>  
        </tr>  
        <tr>  
         <td><input type="radio" name="tablechoice" value="" /></td>  
           <td>李四</td>  
         <td>女</td>  
         <td>北京西城</td>  
        </tr>  
        <tr>  
         <td><input type="radio" name="tablechoice" value="" checked /></td>  
            <td>王五</td>  
         <td>男</td>  
         <td>北京海淀</td>  
        </tr>  
        <tr>  
         <td><input type="radio" name="tablechoice" value="" /></td>  
          <td>找六</td>  
         <td>男</td>  
         <td>北京朝阳</td>   
        </tr>  
        <tr>  
        <td><input type="radio" name="tablechoice" value="" /></td>  
           <td>Rain</td>  
         <td>男</td>  
         <td>北京昌平</td>  
        </tr>  
        </tbody>  
        </table>
    
    
    
    
    </body>
    </html>
  • 相关阅读:
    【故障处理】ORA-12162: TNS:net service name is incorrectly specified (转)
    android studio 编程中用到的快捷键
    java时间格式串
    android Error occurred during initialization of VM Could not reserve enough space for object heap Could not create the Java virtual machine.
    linux安装vmware
    x1c 2017 安装mint18的坑——grub2
    x1c2017 8G版 win linux的取舍纠结记录
    python的try finally (还真不简单)
    kafka+docker+python
    json文件不能有注释
  • 原文地址:https://www.cnblogs.com/huanlei/p/2547238.html
Copyright © 2011-2022 走看看