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

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

May 20, 2016 pm 01:46 PM

简单好用的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;} /*禁用时背景色*/
Nach dem Login kopieren

 

添加菜单,可以在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>]]];
Nach dem Login kopieren

菜单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>;}
Nach dem Login kopieren
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> ......
Nach dem Login kopieren

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> }
Nach dem Login kopieren

 

预览图:

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

Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn

Heiße KI -Werkzeuge

Undresser.AI Undress

Undresser.AI Undress

KI-gestützte App zum Erstellen realistischer Aktfotos

AI Clothes Remover

AI Clothes Remover

Online-KI-Tool zum Entfernen von Kleidung aus Fotos.

Undress AI Tool

Undress AI Tool

Ausziehbilder kostenlos

Clothoff.io

Clothoff.io

KI-Kleiderentferner

AI Hentai Generator

AI Hentai Generator

Erstellen Sie kostenlos Ai Hentai.

Heiße Werkzeuge

Notepad++7.3.1

Notepad++7.3.1

Einfach zu bedienender und kostenloser Code-Editor

SublimeText3 chinesische Version

SublimeText3 chinesische Version

Chinesische Version, sehr einfach zu bedienen

Senden Sie Studio 13.0.1

Senden Sie Studio 13.0.1

Leistungsstarke integrierte PHP-Entwicklungsumgebung

Dreamweaver CS6

Dreamweaver CS6

Visuelle Webentwicklungstools

SublimeText3 Mac-Version

SublimeText3 Mac-Version

Codebearbeitungssoftware auf Gottesniveau (SublimeText3)

Was ist der Zweck des & lt; datalist & gt; Element? Was ist der Zweck des & lt; datalist & gt; Element? Mar 21, 2025 pm 12:33 PM

Der Artikel erörtert den HTML & lt; Datalist & gt; Element, das die Formulare verbessert, indem automatische Vorschläge bereitgestellt, die Benutzererfahrung verbessert und Fehler reduziert werden.Character Count: 159

Was ist der Zweck des & lt; Fortschritts & gt; Element? Was ist der Zweck des & lt; Fortschritts & gt; Element? Mar 21, 2025 pm 12:34 PM

Der Artikel erörtert den HTML & lt; Progress & gt; Element, Absicht, Styling und Unterschiede vom & lt; Meter & gt; Element. Das Hauptaugenmerk liegt auf der Verwendung & lt; Fortschritt & gt; Für Aufgabenabschluss und & lt; Meter & gt; für stati

Was ist der Zweck des & lt; Meter & gt; Element? Was ist der Zweck des & lt; Meter & gt; Element? Mar 21, 2025 pm 12:35 PM

Der Artikel erörtert das HTML & lt; Meter & gt; Element, verwendet zur Anzeige von Skalar- oder Bruchwerten innerhalb eines Bereichs und seine gemeinsamen Anwendungen in der Webentwicklung. Es differenziert & lt; Meter & gt; von & lt; Fortschritt & gt; und Ex

Was ist der Zweck des & lt; iframe & gt; Etikett? Was sind die Sicherheitsüberlegungen bei der Verwendung? Was ist der Zweck des & lt; iframe & gt; Etikett? Was sind die Sicherheitsüberlegungen bei der Verwendung? Mar 20, 2025 pm 06:05 PM

Der Artikel erörtert das & lt; iframe & gt; Der Zweck von Tag, externe Inhalte in Webseiten, seine gemeinsamen Verwendungen, Sicherheitsrisiken und Alternativen wie Objekt -Tags und APIs einzubetten.

Wie verwende ich HTML5 -Formularvalidierungsattribute, um die Benutzereingabe zu validieren? Wie verwende ich HTML5 -Formularvalidierungsattribute, um die Benutzereingabe zu validieren? Mar 17, 2025 pm 12:27 PM

In dem Artikel werden unter Verwendung von HTML5 -Formularvalidierungsattributen wie Erforderlich, Muster, Min, MAX und Längengrenzen erörtert, um die Benutzereingabe direkt im Browser zu validieren.

Was ist das Ansichtsfenster -Meta -Tag? Warum ist es wichtig für reaktionsschnelles Design? Was ist das Ansichtsfenster -Meta -Tag? Warum ist es wichtig für reaktionsschnelles Design? Mar 20, 2025 pm 05:56 PM

In dem Artikel wird das Ansichtsfenster -Meta -Tag erörtert, das für das reaktionsschnelle Webdesign auf mobilen Geräten unerlässlich ist. Es wird erläutert, wie die ordnungsgemäße Verwendung eine optimale Skalierung von Inhalten und Benutzerinteraktion gewährleistet, während Missbrauch zu Design- und Zugänglichkeitsproblemen führen kann.

Was sind die besten Praktiken für die Kompatibilität des Cross-Browsers in HTML5? Was sind die besten Praktiken für die Kompatibilität des Cross-Browsers in HTML5? Mar 17, 2025 pm 12:20 PM

In Artikel werden Best Practices zur Gewährleistung der HTML5-Cross-Browser-Kompatibilität erörtert und sich auf die Erkennung von Merkmalen, die progressive Verbesserung und die Testmethoden konzentriert.

Wie benutze ich die HTML5 & lt; Zeit & gt; Element, um Daten und Zeiten semantisch darzustellen? Wie benutze ich die HTML5 & lt; Zeit & gt; Element, um Daten und Zeiten semantisch darzustellen? Mar 12, 2025 pm 04:05 PM

Dieser Artikel erklärt den HTML5 & lt; Time & gt; Element für semantische Datum/Uhrzeit. Es betont die Wichtigkeit des DateTime-Attributs für die Maschinenlesbarkeit (ISO 8601-Format) neben menschenlesbarem Text, das Zubehör steigert

See all articles