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

简单好用的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

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Difficulty in updating caching of official account web pages: How to avoid the old cache affecting the user experience after version update?Difficulty in updating caching of official account web pages: How to avoid the old cache affecting the user experience after version update?Mar 04, 2025 pm 12:32 PM

The official account web page update cache, this thing is simple and simple, and it is complicated enough to drink a pot of it. You worked hard to update the official account article, but the user still opened the old version. Who can bear the taste? In this article, let’s take a look at the twists and turns behind this and how to solve this problem gracefully. After reading it, you can easily deal with various caching problems, allowing your users to always experience the freshest content. Let’s talk about the basics first. To put it bluntly, in order to improve access speed, the browser or server stores some static resources (such as pictures, CSS, JS) or page content. Next time you access it, you can directly retrieve it from the cache without having to download it again, and it is naturally fast. But this thing is also a double-edged sword. The new version is online,

How to efficiently add stroke effects to PNG images on web pages?How to efficiently add stroke effects to PNG images on web pages?Mar 04, 2025 pm 02:39 PM

This article demonstrates efficient PNG border addition to webpages using CSS. It argues that CSS offers superior performance compared to JavaScript or libraries, detailing how to adjust border width, style, and color for subtle or prominent effect

How do I use HTML5 form validation attributes to validate user input?How do I use HTML5 form validation attributes to validate user input?Mar 17, 2025 pm 12:27 PM

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

What is the purpose of the <datalist> element?What is the purpose of the <datalist> element?Mar 21, 2025 pm 12:33 PM

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

What is the purpose of the <progress> element?What is the purpose of the <progress> element?Mar 21, 2025 pm 12:34 PM

The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

What are the best practices for cross-browser compatibility in HTML5?What are the best practices for cross-browser compatibility in HTML5?Mar 17, 2025 pm 12:20 PM

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

What is the purpose of the <meter> element?What is the purpose of the <meter> element?Mar 21, 2025 pm 12:35 PM

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

What is the purpose of the <iframe> tag? What are the security considerations when using it?What is the purpose of the <iframe> tag? What are the security considerations when using it?Mar 20, 2025 pm 06:05 PM

The article discusses the <iframe> tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment