以前做表格隔行换色,是在tr上添加不同的背景色,但在程序开发的过程需要做判断,不够方便,而且生成的代码也比较多,现在的需求逐渐修改为JQ去控制简洁的表格去显示隔行换色

 <script type="text/javascript" src="http://www.w3school.com.cn/jquery/jquery.js"></script>
<script type="text/javascript">
//表格隔行换色
$(document).ready(function(){
$(".tablebg1 tr:odd").addClass("tabodd1");
$(".tablebg1 tr").mouseover(function(){
$(this).addClass("change");
})
$(".tablebg1 tr").mouseout(function(){
$(this).removeClass("change");
})
$(".tablebg1 tr:even").addClass("tabodd2")
}); </script>
<style type="text/css">
*{ margin:0; padding:0;}
body{ margin:0; padding:20px 100px; font:14px Arial, Helvetica, sans-serif;}
.calendar_tab table { border-left: #E8E8E8 solid 1px; border-top: #E8E8E8 solid 1px; border-collapse: collapse; margin:10px 0;}
.calendar_tab table th { border-right: #E8E8E8 solid 1px; border-bottom: #E8E8E8 solid 1px; background-color: #525254; padding:5px 8px; color:#fff; white-space:nowrap; font-weight:bold;}
.calendar_tab table th a{ color:#fff; text-decoration:underline;}
.calendar_tab table th a:hover{ color:#fff; text-decoration:none;}
.calendar_tab table td { height:auto; border-right: #E8E8E8 solid 1px; border-bottom: #E8E8E8 solid 1px; padding:5px 8px; vertical-align:middle; white-space:nowrap;}
.calendar_tab table td a{ color:#0096d6; text-decoration:underline;}
.calendar_tab table td a:hover{ color:#0096d6; text-decoration:none;} .tabodd1{ background:#fff;}
.tabodd2{ background:#F8F8F8;}
.change{ background:#f0f0f0;} </style>
<div class="calendar_tab">
<table width="100%" id="tablebg1" class="tablebg1" border="0" cellspacing="0" cellpadding="0">
<tr>
<th width="28%">日期 </th>
<th width="72%">选择</th>
</tr>
<tr>
<td>2013-7-01 </td>
<td><select name="select">
<option>工作日</option>
</select></td>
</tr>
<tr>
<td>2013-7-01 </td>
<td><select name="select">
<option>工作日</option>
</select></td>
</tr>
</table>
</div>

菜鸟示例:

日期 选择
2013-7-01 工作日
2013-7-01 工作日

table隔行换色的更多相关文章

  1. jQuery实现table隔行换色和鼠标经过变色

    一.隔行换色 $("tr:odd").css("background-color","#eeeeee"); $("tr:even& ...

  2. table 表格隔行换色实现

    table 表格隔行换色实现 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "htt ...

  3. php29号小结(隔行换色······)

    1.给表单加样式,可以用css.php与js.js这三种,其中最好用php与js,现在很推广用这种. css3样式隔行换色(table中) tr:nth-child(even){ background ...

  4. JQuery 表格 隔行换色 和鼠标滑过的样式

    $(document).ready(function () { $(".Pub_TB tbody tr:even td").css("background-color&q ...

  5. JQuery案例一:实现表格隔行换色

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  6. Bootstrap3基础 table-striped 表格实现隔行换色(浅灰色与白色交替)

      内容 参数   OS   Windows 10 x64   browser   Firefox 65.0.2   framework     Bootstrap 3.3.7   editor    ...

  7. jQuery应用实例2:表格隔行换色

    这里是用JS实现的:http://www.cnblogs.com/xuyiqing/p/8376312.html 接下来利用上一篇提到的选择器利用jQuery实现: 发现原来多行代码这里只需要两行: ...

  8. JS应用实例4:表格隔行换色

    HTML代码: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <t ...

  9. jQuery的基本过滤器与jQuery实现隔行换色实例

    没加过滤器之前: 加过滤器之后: 总的代码: <!DOCTYPE html> <html> <head> <meta charset="UTF-8& ...

随机推荐

  1. shell修改文件名(二)

    我想修改类似如下一批文件的文件名:AA01_01.txtAA01_02.txtAA01_03.txtAA01_04.txt 修改成BB02_01.txtBB02_02.txtBB02_03.txtBB ...

  2. Nginx+Keepalived+Tomcat之动静分离的web集群

    #vi /etc/nginx/nginx.conf############################################user nginx nginx;worker_process ...

  3. [React Fundamentals] Accessing Child Properties

    When you're building your React components, you'll probably want to access child properties of the m ...

  4. [MODx] 8. Snippet get data, chunk display

    Simple Example: Lets process this chunk and output its value. We have this Chunk, called "Welco ...

  5. iOS开发——Swift篇&单例的实现

    Swift实现单例模式 Swift实现单例模式 由于Swift语言弱化了struct和class之间的界限,这里我分别给出自己写的两种的单例实现 class版本: class SwiftSinglet ...

  6. ConvertHelper与泛型集合

    在机房重构时.我们常常会用到ConvertHelper. 它把从数据库中查询到的dateTable(也是一个暂时表)转化为泛型,然后再填充到DataGridView控件中. ConvertHelper ...

  7. 实例源码--ZXing识别条形码和二维码识别源码

      下载源码 技术要点: 1.ZXing库的 使用 2.识别条形码和二 维码 3.自定义视图 4.源码带有非常详 细的中文注释 ...... 详细介绍: 1.ZXing库 ZXing是个很经典的条码/ ...

  8. ie6下子元素撑大父元素

    今天遇到了一个问题.在给a元素定义hover并且增大尺寸时,IE6下该元素会把父元素撑大,而非IE浏览器则是表现为溢出效果不会撑大父元素(我想要的效果).解决IE6的这个问题是采用了一个定位+负边距的 ...

  9. 面试体验:Microsoft 篇(转)

    http://www.cnblogs.com/cathsfz/archive/2012/08/14/microsoft-interview-experience.html 在上一篇<面试体验:G ...

  10. Android Sutido 编译速度优化

    虽然Android Studio 此时已经更新到了Android Studio 2.1版本,build 版本android-studio-bundle-143.2739321.但是在安装该版本都是根据 ...