zoukankan      html  css  js  c++  java
  • 实现 鼠标移动到表格的某行 该行换背景 ---myEclipse编写

    //jQuary代码部分

    <script>
       $(function(){
          $("tr:odd").css("background","#98FB98");
          $("tr:even").css("background","#7FFFD4");
          var trColor;
          $("tr").click(function(){
          /*  :even 选择器 匹配所有索引值为偶数的元素,从 0 开始计数 */
          /*  :odd  选择器 匹配所有索引值为奇数的元素,从 0 开始计数 */
               $("tr:odd").css("background","#98FB98");
               $("tr:even").css("background","#7FFFD4");
               $("tr[check='1']").removeAttr("check");
               $(this).css("background","#FF69B4");
               $(this).attr("check","1");
          });
          $("tr").mouseover(function(){
          if($(this).attr("check")=="1"){
               return
          }
               trColor=$(this).css("background");
               $(this).css({"background":"FFFF00"});
          }).mouseout(function(){
                   if($(this).attr("check")=="1"){
                   return
            }
               $(this).css("background",trColor);
          });
          
         });
        </script>

    //小脚本,定义了一些变量,以及初始化

    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    List<Student> list = new ArrayList<Student>();
          StudentService service = new StudentService();
          list = service.selectAll();
    String className;
    %>

    //设置的样式

    <body>
        <table id="table" border="1" >
        <tr id="tr">
        <td>序号</td>
        <td>姓名</td>
        <td>年龄</td>
        <td>性别</td>
        <td>地址</td>
        <td>联系电话</td>
        </tr>
       <%for(int i=0;i<list.size();i++){
             Student stu=list.get(i);%>
             <tr>
             <td><%=i%></td>
             <td><%=stu.getName() %></td>
             <td><%=stu.getAge() %></td>
             <td><%=stu.getSexID() %></td>
             <td><%=stu.getAddress() %></td>
             <td><%=stu.getPhone() %></td>
             </tr>
             
      <%}%>
    </table>

    </body>

    StudentService 类:

    Student实体类:

  • 相关阅读:
    块级作用域
    作用域变量 var
    unkown类型
    generator (2)
    generator (1)
    generator
    索引类型
    XML 特殊字符处理和 CDATA
    15 个实用的 PHP 正则表达式
    论MySQL数据库中两种数据引擎的差别
  • 原文地址:https://www.cnblogs.com/Dionexin/p/5966263.html
Copyright © 2011-2022 走看看