html 布局;css3+jq 下拉菜单;table分页动态添加行;html5本地存储;简单易用的html框架 - zl1990

WBOY
发布: 2016-05-20 13:46:34
原创
1476 人浏览过

简单好用的html框架,预览图见最后; 源码

1.页面布局使用table;

  table 嵌套 +iframe 布局;

2.下拉菜单为jq+css3 动画;

  css input 无边框,select下拉菜单美化

<span style="color: #008080;">1</span> <span style="color: #000000;">input{appearance:none;background-color:transparent;border: solid 0px #000;} /*input 无边框*/
</span><span style="color: #008080;">2</span> <span style="color: #000000;">input:disabled{background-color:#d2d2d2;border:0px;}
</span><span style="color: #008080;">3</span> <span style="color: #000000;">select {border: solid 1px #000; appearance:none;-moz-appearance:none; -webkit-appearance:none; padding-right: 14px;margin :0px;background: url("../images/arrow.png") no-repeat scroll right center transparent;}
</span><span style="color: #008080;">4</span> <span style="color: #000000;">select::-ms-expand { display: none; } 
</span><span style="color: #008080;">5</span> select:disabled{background-color:#d2d2d2;} /*禁用时背景色*/
登录后复制

 

添加菜单,可以在js目录下的、js/cm_menu.js中添加;

<span style="color: #008080;">1</span> <span style="color: #0000ff;">var</span> menus=<span style="color: #0000ff;">new</span><span style="color: #000000;"> Array();
</span><span style="color: #008080;">2</span> menus[<span style="color: #800080;">0</span>]=[<span style="color: #800000;">'</span><span style="color: #800000;">菜单1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">''</span>,[[<span style="color: #800000;">'</span><span style="color: #800000;">演示1</span><span style="color: #800000;">'</span>,<span style="color: #800000;">'</span><span style="color: #800000;">page/11_page.html</span><span style="color: #800000;">'</span>],[<span style="color: #800000;">'</span><span style="color: #800000;">演示2</span><span style="color: #800000;">'</span>,<span style="color: #800000;">'</span><span style="color: #800000;">page/12_page.html</span><span style="color: #800000;">'</span><span style="color: #000000;">]]];
</span><span style="color: #008080;">3</span> menus[<span style="color: #800080;">1</span>]=[<span style="color: #800000;">'</span><span style="color: #800000;">菜单2</span><span style="color: #800000;">'</span>, <span style="color: #800000;">''</span>,[[<span style="color: #800000;">'</span><span style="color: #800000;">演示1</span><span style="color: #800000;">'</span>,<span style="color: #800000;">'</span><span style="color: #800000;">page/21_page.html</span><span style="color: #800000;">'</span>],[<span style="color: #800000;">'</span><span style="color: #800000;">演示2</span><span style="color: #800000;">'</span>,<span style="color: #800000;">'</span><span style="color: #800000;">page/22_page.html</span><span style="color: #800000;">'</span>]]];
登录后复制

菜单css3

<span style="color: #008080;"> 1</span> <span style="color: #800000;">ul.menu,
</span><span style="color: #008080;"> 2</span> <span style="color: #800000;">ul.*</span>{<span style="color: #ff0000;">margin</span>:<span style="color: #0000ff;">0px</span>;<span style="color: #ff0000;">padding</span>:<span style="color: #0000ff;">0px</span>;}
<span style="color: #008080;"> 3</span> <span style="color: #800000;">ul.menu ul </span>{<span style="color: #ff0000;">padding</span>:<span style="color: #0000ff;">0</span>;<span style="color: #ff0000;">margin</span>:<span style="color: #0000ff;">0</span>;<span style="color: #ff0000;">list-style</span>:<span style="color: #0000ff;">none</span>;<span style="color: #ff0000;">position</span>:<span style="color: #0000ff;">relative</span>;<span style="color: #ff0000;">background</span>:<span style="color: #0000ff;">#ddd</span>;<span style="color: #ff0000;">font-family</span>:<span style="color: #0000ff;">arial, sans-serif</span>;}
<span style="color: #008080;"> 4</span> <span style="color: #800000;">ul.menu </span>{<span style="color: #ff0000;">z-index</span>:<span style="color: #0000ff;">100</span>;<span style="color: #ff0000;">padding</span>:<span style="color: #0000ff;">10px</span>;<span style="color: #ff0000;">border-radius</span>:<span style="color: #0000ff;">10px 10px 0 0</span>;<span style="color: #ff0000;">margin</span>:<span style="color: #0000ff;">0 auto</span>;}
<span style="color: #008080;"> 5</span> <span style="color: #800000;">ul.menu ul </span>{
<span style="color: #008080;"> 6</span> <span style="color: #ff0000;">    z-index</span>:<span style="color: #0000ff;">50</span>;<span style="color: #ff0000;">border-radius</span>:<span style="color: #0000ff;">0 0 10px 10px</span>;
<span style="color: #008080;"> 7</span> <span style="color: #ff0000;">    -webkit-transition</span>:<span style="color: #0000ff;"> 0.5s</span>;
<span style="color: #008080;"> 8</span> <span style="color: #ff0000;">    -moz-transition</span>:<span style="color: #0000ff;"> 0.5s</span>;
<span style="color: #008080;"> 9</span> <span style="color: #ff0000;">    -ms-transition</span>:<span style="color: #0000ff;"> 0.5s</span>;
<span style="color: #008080;">10</span> <span style="color: #ff0000;">    -o-transition</span>:<span style="color: #0000ff;"> 0.5s</span>;
<span style="color: #008080;">11</span> <span style="color: #ff0000;">    transition</span>:<span style="color: #0000ff;"> 0.5s</span>;
<span style="color: #008080;">12</span> }
<span style="color: #008080;">13</span> <span style="color: #800000;">ul.menu li </span>{<span style="color: #ff0000;">line-height</span>:<span style="color: #0000ff;">30px</span>;<span style="color: #ff0000;">position</span>:<span style="color: #0000ff;">relative</span>;<span style="color: #ff0000;">text-indent</span>:<span style="color: #0000ff;">10px</span>;<span style="color: #ff0000;">list-style-type</span>:<span style="color: #0000ff;">none</span>;}
<span style="color: #008080;">14</span> <span style="color: #800000;">ul.menu > li </span>{<span style="color: #ff0000;">margin-top</span>:<span style="color: #0000ff;">2px</span>;<span style="color: #ff0000;">font-size</span>:<span style="color: #0000ff;">12px</span>;}
<span style="color: #008080;">15</span> <span style="color: #800000;">ul.menu > li a </span>{<span style="color: #ff0000;">font</span>:<span style="color: #0000ff;">normal 12px/30px arial, sans-serif</span>;<span style="color: #ff0000;">color</span>:<span style="color: #0000ff;">#fff</span>;<span style="color: #ff0000;">text-decoration</span>:<span style="color: #0000ff;">none</span>;}
<span style="color: #008080;">16</span> <span style="color: #800000;">ul.menu label.open </span>{<span style="color: #ff0000;">display</span>:<span style="color: #0000ff;">block</span>;<span style="color: #ff0000;">background</span>:<span style="color: #0000ff;"> #DEEEF1 url("/jscss/demoimg/201208/d-arrow.gif") no-repeat 170px 12px</span>;<span style="color: #ff0000;">line-height</span>:<span style="color: #0000ff;">30px</span>;<span style="color: #ff0000;">position</span>:<span style="color: #0000ff;">relative</span>;<span style="color: #ff0000;">z-index</span>:<span style="color: #0000ff;">100</span>;<span style="color: #ff0000;">font</span>:<span style="color: #0000ff;">normal 12px/30px arial, sans-serif</span>;<span style="color: #ff0000;">color</span>:<span style="color: #0000ff;">#000</span>;<span style="color: #ff0000;">font-weight</span>:<span style="color: #0000ff;">900</span>;<span style="color: #ff0000;">;border-radius</span>:<span style="color: #0000ff;">10px 10px 0 0</span>;}
<span style="color: #008080;">17</span> <span style="color: #800000;">ul.menu label.open b </span>{<span style="color: #ff0000;">color</span>:<span style="color: #0000ff;">#DEEEF1</span>;}
<span style="color: #008080;">18</span> <span style="color: #800000;">ul.menu span </span>{<span style="color: #ff0000;">display</span>:<span style="color: #0000ff;">block</span>;<span style="color: #ff0000;">background</span>:<span style="color: #0000ff;">#00c</span>;<span style="color: #ff0000;">line-height</span>:<span style="color: #0000ff;">30px</span>;<span style="color: #ff0000;">position</span>:<span style="color: #0000ff;">relative</span>;<span style="color: #ff0000;">z-index</span>:<span style="color: #0000ff;">100</span>;<span style="color: #ff0000;">border-radius</span>:<span style="color: #0000ff;">10px 10px 0 0</span>;}
<span style="color: #008080;">19</span> <span style="color: #800000;">ul.menu label img </span>{<span style="color: #ff0000;">position</span>:<span style="color: #0000ff;">absolute</span>;<span style="color: #ff0000;">left</span>:<span style="color: #0000ff;">0</span>;<span style="color: #ff0000;">top</span>:<span style="color: #0000ff;">0</span>;<span style="color: #ff0000;">width</span>:<span style="color: #0000ff;">100%</span>;<span style="color: #ff0000;">height</span>:<span style="color: #0000ff;">30px</span>;}
<span style="color: #008080;">20</span> 
<span style="color: #008080;">21</span> <span style="color: #800000;">ul.menu ul li </span>{<span style="color: #ff0000;">margin-top</span>:<span style="color: #0000ff;">-30px</span>;
<span style="color: #008080;">22</span> <span style="color: #ff0000;">    -webkit-transition</span>:<span style="color: #0000ff;"> 0.5s</span>;
<span style="color: #008080;">23</span> <span style="color: #ff0000;">    -moz-transition</span>:<span style="color: #0000ff;"> 0.5s</span>;
<span style="color: #008080;">24</span> <span style="color: #ff0000;">    -ms-transition</span>:<span style="color: #0000ff;"> 0.5s</span>;
<span style="color: #008080;">25</span> <span style="color: #ff0000;">    -o-transition</span>:<span style="color: #0000ff;"> 0.5s</span>;
<span style="color: #008080;">26</span> <span style="color: #ff0000;">    transition</span>:<span style="color: #0000ff;"> 0.5s</span>;
<span style="color: #008080;">27</span> }
<span style="color: #008080;">28</span> <span style="color: #800000;">ul.menu ul li a </span>{<span style="color: #ff0000;">display</span>:<span style="color: #0000ff;">block</span>;<span style="color: #ff0000;">font</span>:<span style="color: #0000ff;">normal 11px/30px arial, sans-serif</span>;<span style="color: #ff0000;">color</span>:<span style="color: #0000ff;">#000</span>;<span style="color: #ff0000;">background</span>:<span style="color: #0000ff;">#ccc</span>;}
<span style="color: #008080;">29</span> <span style="color: #800000;">ul.menu ul li a:hover </span>{<span style="color: #ff0000;">background</span>:<span style="color: #0000ff;">#ddd</span>;}
<span style="color: #008080;">30</span> <span style="color: #800000;">ul.menu input </span>{<span style="color: #ff0000;">position</span>:<span style="color: #0000ff;">absolute</span>;<span style="color: #ff0000;">left</span>:<span style="color: #0000ff;">-9999px</span>;}
<span style="color: #008080;">31</span> 
<span style="color: #008080;">32</span> <span style="color: #800000;">ul.menu li input:checked + label </span>{<span style="color: #ff0000;">background</span>:<span style="color: #0000ff;">#069</span>;} 
<span style="color: #008080;">33</span> <span style="color: #800000;">ul.menu li input:checked ~ ul </span>{<span style="color: #ff0000;">background</span>:<span style="color: #0000ff;">#ccc</span>;<span style="color: #ff0000;">padding-bottom</span>:<span style="color: #0000ff;">10px</span>;}
<span style="color: #008080;">34</span> <span style="color: #800000;">ul.menu li input:checked ~ ul li </span>{<span style="color: #ff0000;">margin-top</span>:<span style="color: #0000ff;">0</span>;}  
<span style="color: #008080;">35</span> 
<span style="color: #008080;">36</span> <span style="color: #800000;">ul.menu label.close </span>{<span style="color: #ff0000;">display</span>:<span style="color: #0000ff;">block</span>;<span style="color: #ff0000;">height</span>:<span style="color: #0000ff;">30px</span>;<span style="color: #ff0000;">background</span>:<span style="color: #0000ff;">transparent url("/jscss/demoimg/201208/u-arrow.gif") no-repeat 170px 12px</span>;<span style="color: #ff0000;">line-height</span>:<span style="color: #0000ff;">30px</span>;<span style="color: #ff0000;">position</span>:<span style="color: #0000ff;">relative</span>;<span style="color: #ff0000;">left</span>:<span style="color: #0000ff;">0</span>;<span style="color: #ff0000;">z-index</span>:<span style="color: #0000ff;">90</span>;<span style="color: #ff0000;">margin-top</span>:<span style="color: #0000ff;">-30px</span>} 
<span style="color: #008080;">37</span> <span style="color: #800000;">ul.menu input.tabs:checked ~ label.close </span>{<span style="color: #ff0000;">display</span>:<span style="color: #0000ff;">block</span>;<span style="color: #ff0000;">z-index</span>:<span style="color: #0000ff;">200</span>;}
<span style="color: #008080;">38</span> <span style="color: #800000;">ul.menu input.close:checked + label.close </span>{<span style="color: #ff0000;">display</span>:<span style="color: #0000ff;">none</span>;}
<span style="color: #008080;">39</span> <span style="color: #800000;">ul.menu input.close:checked ~ ul </span>{<span style="color: #ff0000;">background</span>:<span style="color: #0000ff;">#ddd</span>;<span style="color: #ff0000;">padding-bottom</span>:<span style="color: #0000ff;">0</span>;}
<span style="color: #008080;">40</span> <span style="color: #800000;">ul.menu input.close:checked ~ ul li </span>{<span style="color: #ff0000;">margin-top</span>:<span style="color: #0000ff;">-30px</span>;}
登录后复制
View Code

 

部分代码如下:

<span style="color: #008080;"> 1</span> <span style="color: #000000;">......
</span><span style="color: #008080;"> 2</span>         <td height="<span" style="color: #800000;">"<span style="color: #800000;">100%</span><span style="color: #800000;">"</span> style=<span style="color: #800000;">"</span><span style="color: #800000;">background-image:url(images/menu_bgT.gif); background-repeat:no-repeat</span><span style="color: #800000;">"</span> valign=<span style="color: #800000;">"</span><span style="color: #800000;">top</span><span style="color: #800000;">"</span>>
<span style="color: #008080;"> 3</span>         <ul id="navmenu" style="color: #0000ff;">class=<span style="color: #800000;">"</span><span style="color: #800000;">menu</span><span style="color: #800000;">"</span>>
<span style="color: #008080;"> 4</span>         </ul>
<span style="color: #008080;"> 5</span>         </td>
<span style="color: #008080;"> 6</span> <span style="color: #000000;">......
</span><span style="color: #008080;"> 7</span> <script type="<span" style="color: #800000;">"<span style="color: #800000;">text/javascript<span style="color: #800000;">">
<span style="color: #008080;"> 8     <span style="color: #0000ff;">try<span style="color: #000000;"> {
<span style="color: #008080;"> 9              <span style="color: #0000ff;">for (i=<span style="color: #800080;">0; i < menus.length; i++<span style="color: #000000;">)
<span style="color: #008080;">10 <span style="color: #000000;">            {
<span style="color: #008080;">11                 $(<span style="color: #800000;">"<span style="color: #800000;">#navmenu<span style="color: #800000;">").append(<span style="color: #800000;">'<span style="color: #800000;"><li id=level<span style="color: #800000;">' + i + <span style="color: #800000;">'<span style="color: #800000;">><span style="color: #800000;">'<span style="color: #000000;">);
<span style="color: #008080;">12                 $(<span style="color: #800000;">'<span style="color: #800000;">#level<span style="color: #800000;">' + i ).append(<span style="color: #800000;">'<span style="color: #800000;"><input type="radio" name="tab" id=tab<span style="color: #800000;">' + i + <span style="color: #800000;">'<span style="color: #800000;">a class="tabs"><span style="color: #800000;">'<span style="color: #000000;">);
<span style="color: #008080;">13                 $(<span style="color: #800000;">'<span style="color: #800000;">#level<span style="color: #800000;">' + i ).append(<span style="color: #800000;">'<span style="color: #800000;"><label for=tab<span style="color: #800000;">' + i + <span style="color: #800000;">'<span style="color: #800000;">a class="open" accesskey="2"><span style="color: #800000;">' + menus[i][<span style="color: #800080;">0] + <span style="color: #800000;">'<span style="color: #800000;"><span style="color: #800000;">'<span style="color: #000000;">); /*添加第一级菜单*/
<span style="color: #008080;">14                 $(<span style="color: #800000;">'<span style="color: #800000;">#level<span style="color: #800000;">' + i ).append(<span style="color: #800000;">'<span style="color: #800000;"><input type="radio" name="tab" id="tab<span style="color: #800000;">' + i + <span style="color: #800000;">'<span style="color: #800000;">ac" class="tabs close"><span style="color: #800000;">'<span style="color: #000000;">);
<span style="color: #008080;">15                 $(<span style="color: #800000;">'<span style="color: #800000;">#level<span style="color: #800000;">' + i ).append(<span style="color: #800000;">'<span style="color: #800000;"><label for=tab<span style="color: #800000;">' + i + <span style="color: #800000;">'<span style="color: #800000;">ac class="close" accesskey="3"><span style="color: #800000;">'<span style="color: #000000;">);
<span style="color: #008080;">16                 $(<span style="color: #800000;">'<span style="color: #800000;">#level<span style="color: #800000;">' + i ).append(<span style="color: #800000;">'<span style="color: #800000;"><ul id=second<span style="color: #800000;">' + i + <span style="color: #800000;">'<span style="color: #800000;">><span style="color: #800000;">'<span style="color: #000000;">);
<span style="color: #008080;">17                 <span style="color: #0000ff;">var submenu=menus[i][<span style="color: #800080;">2<span style="color: #000000;">];
<span style="color: #008080;">18                 <span style="color: #0000ff;">for (j=<span style="color: #800080;">0; j < submenu.length; j++<span style="color: #000000;">)
<span style="color: #008080;">19 <span style="color: #000000;">                {/*添加二级菜单*/
<span style="color: #008080;">20                     $(<span style="color: #800000;">'<span style="color: #800000;">#second<span style="color: #800000;">' + i).append(<span style="color: #800000;">'<span style="color: #800000;"><li><a href=<span style="color: #800000;">' + submenu[j][<span style="color: #800080;">1] + <span style="color: #800000;">'<span style="color: #800000;">?<span style="color: #800000;">'+ Math.random() +<span style="color: #800000;">'<span style="color: #800000;"> target=page><span style="color: #800000;">' + submenu[j][<span style="color: #800080;">0] + <span style="color: #800000;">'<span style="color: #800000;"><span style="color: #800000;">'<span style="color: #000000;">);    
<span style="color: #008080;">21 <span style="color: #000000;">                }
<span style="color: #008080;">22                 $(<span style="color: #800000;">'<span style="color: #800000;">#level<span style="color: #800000;">' + i ).append(<span style="color: #800000;">'<span style="color: #800000;"><span style="color: #800000;">'<span style="color: #000000;">);
<span style="color: #008080;">23                 $(<span style="color: #800000;">"<span style="color: #800000;">#navmenu<span style="color: #800000;">").append(<span style="color: #800000;">'<span style="color: #800000;"><span style="color: #800000;">'<span style="color: #000000;">);
<span style="color: #008080;">24 <span style="color: #000000;">            }
<span style="color: #008080;">25 <span style="color: #000000;">    } 
<span style="color: #008080;">26     <span style="color: #0000ff;">catch<span style="color: #000000;"> (e) 
<span style="color: #008080;">27 <span style="color: #000000;">    {/*新的js中部分属性不支持,提示异常*/
<span style="color: #008080;">28         alert(e.name  + e.message + <span style="color: #800000;">"<span style="color: #800000;">\n<span style="color: #800000;">"  + <span style="color: #800000;">"<span style="color: #800000;">浏览器版本太低请尝试使用Firfox、谷歌浏览器、IE9+ 浏览器预览\n<span style="color: #800000;">"<span style="color: #000000;">);
<span style="color: #008080;">29 <span style="color: #000000;">    }
<span style="color: #008080;">30 
<span style="color: #008080;">31     $(<span style="color: #800000;">'<span style="color: #800000;">#tab0a<span style="color: #800000;">').attr(<span style="color: #800000;">"<span style="color: #800000;">checked<span style="color: #800000;">", <span style="color: #0000ff;">true<span style="color: #000000;">);  /*第一个菜单选中*/
<span style="color: #008080;">32 </script>
<span style="color: #008080;">33</span> ......
登录后复制

3.table 分页显示 ,新增行,使用jq;

<span style="color: #008080;">  1</span> <span style="color: #0000ff;">var</span> currentPage = 1; <span style="color: #008000;">/*</span><span style="color: #008000;">当前是第几页</span><span style="color: #008000;">*/</span>
<span style="color: #008080;">  2</span> <span style="color: #0000ff;">var</span> showTableTr  = 10; <span style="color: #008000;">/*</span><span style="color: #008000;">每页显示多少行</span><span style="color: #008000;">*/</span>
<span style="color: #008080;">  3</span> 
<span style="color: #008080;">  4</span> <span style="color: #008000;">/*</span><span style="color: #008000;">新增行</span><span style="color: #008000;">*/</span>
<span style="color: #008080;">  5</span> <span style="color: #0000ff;">function</span><span style="color: #000000;"> addTr()
</span><span style="color: #008080;">  6</span> <span style="color: #000000;">{
</span><span style="color: #008080;">  7</span>     sum++<span style="color: #000000;">;
</span><span style="color: #008080;">  8</span>     <span style="color: #008000;">/*</span><span style="color: #008000;">显示隐藏的行</span><span style="color: #008000;">*/</span>
<span style="color: #008080;">  9</span>     $('tr[name="hidetr"]:last').find("th").eq(0).text($("#tableList tr").length -2<span style="color: #000000;">);
</span><span style="color: #008080;"> 10</span>     $('tr[name="hidetr"]:last'<span style="color: #000000;">).show();
</span><span style="color: #008080;"> 11</span>     
<span style="color: #008080;"> 12</span>     <span style="color: #008000;">/*</span><span style="color: #008000;">复制最后一行,添加到最后一行后面,然后隐藏</span><span style="color: #008000;">*/</span>
<span style="color: #008080;"> 13</span>     $('tr[name="hidetr"]:last').after($('tr[name="hidetr"]:last').clone(<span style="color: #0000ff;">true</span><span style="color: #000000;">));
</span><span style="color: #008080;"> 14</span>     $('tr[name="hidetr"]:last'<span style="color: #000000;">).hide();
</span><span style="color: #008080;"> 15</span>     
<span style="color: #008080;"> 16</span>     <span style="color: #0000ff;">if</span>("BGCgray" == $('tr[name="hidetr"]:last').attr('class'<span style="color: #000000;">))
</span><span style="color: #008080;"> 17</span> <span style="color: #000000;">    {
</span><span style="color: #008080;"> 18</span>             $('tr[name="hidetr"]:last').removeClass('BGCgray'<span style="color: #000000;">);
</span><span style="color: #008080;"> 19</span> <span style="color: #000000;">    }
</span><span style="color: #008080;"> 20</span>     <span style="color: #0000ff;">else</span> 
<span style="color: #008080;"> 21</span> <span style="color: #000000;">    {
</span><span style="color: #008080;"> 22</span>         $('tr[name="hidetr"]:last').addClass('BGCgray'<span style="color: #000000;">);    
</span><span style="color: #008080;"> 23</span> <span style="color: #000000;">    }
</span><span style="color: #008080;"> 24</span>     
<span style="color: #008080;"> 25</span>     <span style="color: #0000ff;">if</span>(currentPage !=<span style="color: #000000;"> parseInt(getSumPage()))
</span><span style="color: #008080;"> 26</span> <span style="color: #000000;">    {    
</span><span style="color: #008080;"> 27</span> <span style="color: #000000;">        tabPaging(parseInt(getSumPage()));
</span><span style="color: #008080;"> 28</span> <span style="color: #000000;">    }
</span><span style="color: #008080;"> 29</span> <span style="color: #000000;">}
</span><span style="color: #008080;"> 30</span> <span style="color: #008000;">/*</span><span style="color: #008000;">删除行</span><span style="color: #008000;">*/</span>
<span style="color: #008080;"> 31</span> <span style="color: #0000ff;">function</span><span style="color: #000000;"> delTr(node) {   
</span><span style="color: #008080;"> 32</span>     <span style="color: #0000ff;">var</span> tr1 =<span style="color: #000000;"> node.parentNode.parentNode;  
</span><span style="color: #008080;"> 33</span>     <span style="color: #0000ff;">var</span> index =<span style="color: #000000;"> tr1.rowIndex;
</span><span style="color: #008080;"> 34</span>         <span style="color: #0000ff;">var</span> tab = document.getElementById("tableList"<span style="color: #000000;">);
</span><span style="color: #008080;"> 35</span> 
<span style="color: #008080;"> 36</span> <span style="color: #000000;">        tab.deleteRow(index);
</span><span style="color: #008080;"> 37</span> 
<span style="color: #008080;"> 38</span>         <span style="color: #008000;">/*</span><span style="color: #008000;">序号重排</span><span style="color: #008000;">*/</span>
<span style="color: #008080;"> 39</span>         <span style="color: #0000ff;">for</span>(i = index; i )
<span style="color: #008080;"> 40</span> <span style="color: #000000;">        {
</span><span style="color: #008080;"> 41</span>             tab.rows[i].cells[0].innerHTML =<span style="color: #000000;"> i.toString();    
</span><span style="color: #008080;"> 42</span> <span style="color: #000000;">        }
</span><span style="color: #008080;"> 43</span>         
<span style="color: #008080;"> 44</span> <span style="color: #000000;">        tabPaging(currentPage);
</span><span style="color: #008080;"> 45</span> <span style="color: #000000;">}  
</span><span style="color: #008080;"> 46</span> <span style="color: #008000;">/*</span><span style="color: #008000;">分页</span><span style="color: #008000;">*/</span>
<span style="color: #008080;"> 47</span> <span style="color: #0000ff;">function</span><span style="color: #000000;"> tabPaging(page)
</span><span style="color: #008080;"> 48</span> <span style="color: #000000;">{    
</span><span style="color: #008080;"> 49</span>     currentPage =<span style="color: #000000;"> page;
</span><span style="color: #008080;"> 50</span>     <span style="color: #0000ff;">for</span>(i = 1; i )
<span style="color: #008080;"> 51</span> <span style="color: #000000;">    {
</span><span style="color: #008080;"> 52</span>         $("#tableList tr"<span style="color: #000000;">).eq(i).hide();    
</span><span style="color: #008080;"> 53</span> <span style="color: #000000;">    }
</span><span style="color: #008080;"> 54</span>     
<span style="color: #008080;"> 55</span>     <span style="color: #0000ff;">var</span> end = (page*showTableTr) > getTabTrLength("tableList")? getTabTrLength("tableList") : page*<span style="color: #000000;">showTableTr;
</span><span style="color: #008080;"> 56</span>     <span style="color: #0000ff;">for</span>(i = (page - 1)*showTableTr + 1; i )
<span style="color: #008080;"> 57</span> <span style="color: #000000;">    {
</span><span style="color: #008080;"> 58</span>         $("#tableList tr"<span style="color: #000000;">).eq(i).show();    
</span><span style="color: #008080;"> 59</span> <span style="color: #000000;">    }
</span><span style="color: #008080;"> 60</span> <span style="color: #000000;">}
</span><span style="color: #008080;"> 61</span> <span style="color: #0000ff;">function</span><span style="color: #000000;"> getTabTrLength(tname)
</span><span style="color: #008080;"> 62</span> <span style="color: #000000;">{
</span><span style="color: #008080;"> 63</span>         <span style="color: #0000ff;">return</span> $("#" + tname + " tr").length - 3<span style="color: #000000;">;
</span><span style="color: #008080;"> 64</span> <span style="color: #000000;">}
</span><span style="color: #008080;"> 65</span> <span style="color: #008000;">/*</span><span style="color: #008000;">上一页</span><span style="color: #008000;">*/</span>
<span style="color: #008080;"> 66</span> <span style="color: #0000ff;">function</span><span style="color: #000000;"> prePage()
</span><span style="color: #008080;"> 67</span> <span style="color: #000000;">{
</span><span style="color: #008080;"> 68</span>     <span style="color: #0000ff;">if</span>(1 ==<span style="color: #000000;"> currentPage)
</span><span style="color: #008080;"> 69</span> <span style="color: #000000;">    {
</span><span style="color: #008080;"> 70</span>         currentPage =<span style="color: #000000;">parseInt(getSumPage());
</span><span style="color: #008080;"> 71</span> <span style="color: #000000;">    }
</span><span style="color: #008080;"> 72</span>     <span style="color: #0000ff;">else</span> 
<span style="color: #008080;"> 73</span> <span style="color: #000000;">    {
</span><span style="color: #008080;"> 74</span>         --<span style="color: #000000;">currentPage;    
</span><span style="color: #008080;"> 75</span> <span style="color: #000000;">    }
</span><span style="color: #008080;"> 76</span> <span style="color: #000000;">    tabPaging(currentPage);
</span><span style="color: #008080;"> 77</span> <span style="color: #000000;">}
</span><span style="color: #008080;"> 78</span> <span style="color: #008000;">/*</span><span style="color: #008000;">下一页</span><span style="color: #008000;">*/</span>
<span style="color: #008080;"> 79</span> <span style="color: #0000ff;">function</span><span style="color: #000000;"> nextPage()
</span><span style="color: #008080;"> 80</span> <span style="color: #000000;">{
</span><span style="color: #008080;"> 81</span>     <span style="color: #0000ff;">if</span>(parseInt(getSumPage()) ==<span style="color: #000000;"> currentPage)
</span><span style="color: #008080;"> 82</span> <span style="color: #000000;">    {
</span><span style="color: #008080;"> 83</span>         currentPage = 1<span style="color: #000000;">;
</span><span style="color: #008080;"> 84</span> <span style="color: #000000;">    }
</span><span style="color: #008080;"> 85</span>     <span style="color: #0000ff;">else</span> 
<span style="color: #008080;"> 86</span> <span style="color: #000000;">    {
</span><span style="color: #008080;"> 87</span>         ++<span style="color: #000000;">currentPage;    
</span><span style="color: #008080;"> 88</span> <span style="color: #000000;">    }
</span><span style="color: #008080;"> 89</span> <span style="color: #000000;">    tabPaging(currentPage);
</span><span style="color: #008080;"> 90</span> <span style="color: #000000;">}
</span><span style="color: #008080;"> 91</span> 
<span style="color: #008080;"> 92</span> <span style="color: #008000;">/*</span><span style="color: #008000;">总共可以分几页</span><span style="color: #008000;">*/</span>
<span style="color: #008080;"> 93</span> <span style="color: #0000ff;">function</span><span style="color: #000000;"> getSumPage() {
</span><span style="color: #008080;"> 94</span>     sumtr = getTabTrLength("tableList"<span style="color: #000000;">);
</span><span style="color: #008080;"> 95</span>     <span style="color: #0000ff;">return</span> (sumtr/showTableTr + (sumtr%showTableTr == 0 ? 0 : 1)); 
<span style="color: #008080;"> 96</span> <span style="color: #000000;">}
</span><span style="color: #008080;"> 97</span> 
<span style="color: #008080;"> 98</span> <span style="color: #0000ff;">function</span><span style="color: #000000;"> setKey(_key,val)
</span><span style="color: #008080;"> 99</span> <span style="color: #000000;">{
</span><span style="color: #008080;">100</span> <span style="color: #000000;">    localStorage.setItem(_key,val);
</span><span style="color: #008080;">101</span> <span style="color: #000000;">}
</span><span style="color: #008080;">102</span> <span style="color: #0000ff;">function</span><span style="color: #000000;"> getKey (_key) {
</span><span style="color: #008080;">103</span>     <span style="color: #0000ff;">return</span><span style="color: #000000;"> localStorage.getItem(_key);
</span><span style="color: #008080;">104</span> <span style="color: #000000;">}
</span><span style="color: #008080;">105</span> 
<span style="color: #008080;">106</span> <span style="color: #008000;">/*</span><span style="color: #008000;">  提交</span><span style="color: #008000;">*/</span>
<span style="color: #008080;">107</span> <span style="color: #0000ff;">function</span><span style="color: #000000;"> submitChange()
</span><span style="color: #008080;">108</span> <span style="color: #000000;">{
</span><span style="color: #008080;">109</span>     <span style="color: #008000;">/*</span><span style="color: #008000;">保存当前页</span><span style="color: #008000;">*/</span>
<span style="color: #008080;">110</span>     setKey("currentPage"<span style="color: #000000;">,currentPage);
</span><span style="color: #008080;">111</span> <span style="color: #000000;">}
</span><span style="color: #008080;">112</span> 
<span style="color: #008080;">113</span> <span style="color: #008000;">/*</span><span style="color: #008000;">初始化数据</span><span style="color: #008000;">*/</span>
<span style="color: #008080;">114</span> <span style="color: #0000ff;">function</span><span style="color: #000000;"> htmlload()
</span><span style="color: #008080;">115</span> <span style="color: #000000;">{
</span><span style="color: #008080;">116</span>     <span style="color: #0000ff;">if</span><span style="color: #000000;">(window.localStorage)
</span><span style="color: #008080;">117</span> <span style="color: #000000;">    {
</span><span style="color: #008080;">118</span>         <span style="color: #0000ff;">var</span> a = <span style="color: #0000ff;">null</span><span style="color: #000000;">;
</span><span style="color: #008080;">119</span>         <span style="color: #0000ff;">if</span>(getKey("currentPage") ==<span style="color: #000000;"> a)
</span><span style="color: #008080;">120</span> <span style="color: #000000;">        {
</span><span style="color: #008080;">121</span>             currentPage = 1<span style="color: #000000;">;    
</span><span style="color: #008080;">122</span> <span style="color: #000000;">        }
</span><span style="color: #008080;">123</span>         <span style="color: #0000ff;">else</span> 
<span style="color: #008080;">124</span> <span style="color: #000000;">        {
</span><span style="color: #008080;">125</span>             currentPage = getKey("currentPage"<span style="color: #000000;">);
</span><span style="color: #008080;">126</span> <span style="color: #000000;">        }
</span><span style="color: #008080;">127</span> <span style="color: #000000;">    }
</span><span style="color: #008080;">128</span>     <span style="color: #0000ff;">else</span> 
<span style="color: #008080;">129</span> <span style="color: #000000;">    {
</span><span style="color: #008080;">130</span>         alert('该浏览器不支持html5,请使用Google,Firfox等浏览器'<span style="color: #000000;">);
</span><span style="color: #008080;">131</span> <span style="color: #000000;">    }
</span><span style="color: #008080;">132</span>     $('tr[name="hidetr"]:last'<span style="color: #000000;">).hide();    
</span><span style="color: #008080;">133</span>     
<span style="color: #008080;">134</span> <span style="color: #000000;">    tabPaging(currentPage);
</span><span style="color: #008080;">135</span> }
登录后复制

 

预览图:

html 布局;css3+jq 下拉菜单;table分页动态添加行;html5本地存储;简单易用的html框架 - zl1990

来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板