zoukankan      html  css  js  c++  java
  • jQuery对表格进行类样式

    <%-- <%@ page language="java" contentType="text/html; charset=utf-8"
        pageEncoding="utf-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Jquery演示示例</title>
    <style type="text/css">
    #tb{
    border:1px solid blue;
     500px;
    border-collapse: collapse;
    cursor:point;
    }
    #tb td{
    border:1px solid blue;
    padding:3px;
    }
    #tb th{
    background: gray;
    padding: 3px;
    }
    .even{
    background:red;
    }
    .over{
    background: yellow;
    }
    </style>
     <script type="text/javascript" src="<c:url value='/js/jquery-3.1.0.js'/>"></script>
     <script type="text/javascript">
       $(function(){
    	   $("#td tr:odd").addClass("even");//给奇数行添加类样式
    	   //分两步实现
    	  /*  $("#tb tr:gt(0)").mouseover(function(){
    		   //注意,这里的this对象是js-dom对象,如果想调用jQuery中的方法,得转化成JQuery中的对象
    		   $(this).addClass("over");
    		   
    	   });
    	   $("#tb tr:gt(0)").mouseout(function(){
    		   $(this).removeClass("over");
    		   
    	   }); */
    	   //行云流水
    	   $("#tb tr:gt(0)").mouseover(function(){
    		   $(this).addClass("over");
    	   }).mouseout(function(){
    		   $(this).removeClass("over");
    	   });  
       });
     </script>
    </head>
    <body>
    <table id="tb">
    <tr><th>姓名</th> <th>年龄</th> <th>电话</th></tr>
    <tr><td>张三</td> <td>22</td> <td>13107172719893</td></tr>
    <tr><td>王五</td> <td>42</td> <td>13107176587271</td></tr>
    <tr><td>西欧</td> <td>32</td> <td>1310121323893</td></tr>
    <tr><td>李四</td> <td>22</td> <td>13107172719893</td></tr>
    </table>
    
    </body>
    </html> --%>
    <%@ page language="java" contentType="text/html; charset=UTF-8"
    	pageEncoding="UTF-8"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    	
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    	<head>
    		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    		<title>JQuery演示示例</title>
    		
    		<style type="text/css">
    			#tb{
    				border: 1px solid blue;
    				500px;
    				border-collapse: collapse;
    				cursor:point;
    			}
    			#tb td{
    				border: 1px solid blue;
    				padding:3px;
    			}
    			#tb th{
    				background:gray;
    				padding:3px;
    			}
    			
    			.even{
    				background: red;
    			}
    			.over{
    				background: yellow;
    			}
    			
    		</style>
    		
    		<script type="text/javascript" src="<c:url value='/js/jquery-3.1.0.js'/>"></script>
    		
    		<script type="text/javascript">
                 $( function(){
                	 $("#tb tr:odd").addClass("even"); //给奇数行添加类样式
                	 
                	 /*分两步实现
                	 $("#tb tr:gt(0)").mouseover(function(){
                		 //注意,这里的this对象是js-dom对象,如果想调用jQuery中的方法,得转换成JQuery对象
                		 //alert( this instanceof $); //false
                		 $(this).addClass("over");
                	 });
                	 $("#tb tr:gt(0)").mouseout(function(){
                		 $(this).removeClass("over");
                	 });
                	 */
                	 
                	 //行云流水
                	 $("#tb tr:gt(0)").mouseover(function(){
                		$(this).addClass("over"); 
                	 }).mouseout(function(){
                		 $(this).removeClass("over");
                	 });
                	 
                 });
    		</script>
    		
    	</head>
    	<body>
    		<table id="tb">
    			<tr> <th>姓名</th> <th>年龄</th> <th>电话</th></tr>
    			<tr> <td>张三</td> <td>22</td>  <td>13512345678</td>
    			<tr> <td>张三</td> <td>22</td>  <td>13512345678</td>
    			<tr> <td>张三</td> <td>22</td>  <td>13512345678</td>
    			<tr> <td>张三</td> <td>22</td>  <td>13512345678</td>
    			<tr> <td>张三</td> <td>22</td>  <td>13512345678</td>
    		</table>
    	</body>
    </html>
    

      

  • 相关阅读:
    [安装程序配置服务器失败]解决SQL Server2000安装失败
    C# 操作 XML 增 删 改 查
    批量修改文件的编码格式
    获取SqlServer2005表结构(字段,主键,外键,递增,描述)
    .NET 特性Attribute[一]
    windows2003远程桌面退出后系统自动注销的解决方法
    SqlServer 无日志文件附加
    接受来自服务器的数据连接时发生超时(30000 毫秒)问题原因及解决方法
    .net中数据集合导出为Excel(支持泛型及显示字段顺序,可自定义显示列名)
    EF中自编写SQL脚本查询结果(适用于复杂SQL逻辑提高查询效率)
  • 原文地址:https://www.cnblogs.com/1314wamm/p/6523247.html
Copyright © 2011-2022 走看看