Quantcast
Channel: HTML5
Viewing all articles
Browse latest Browse all 663

用 jquery 统计子菜单的条数 (demo)

$
0
0

http://www.freejs.net/article_tabbiaoqian_58.html   jquery tab特效~ (类似选项卡)

 

  1. <!doctype html>  
  2. <html lang="en">  
  3. <head>  
  4.     <meta charset="UTF-8">  
  5.     <title>Tabs</title>  
  6.     <style type="text/css">  
  7.     /* Remove margin padding */  
  8.     body,h1,h2,h3,h4,h5,h6,hr,p,blockquote,dl,dt,dd,ul,ol,li,pre,form,fieldset,legend,button,input,textarea,th,td { margin:0; padding:0; }  
  9.   
  10.     /* Default Font */  
  11.     body,button,input,select,textarea { font:12px/1.5 \5b8b\4f53,arial,sans-serif; }  
  12.     h1,h2,h3,h4,h5,h6 { font-size:100%; }  
  13.     address,cite,dfn,em,var { font-style:normal; }  
  14.     code,kbd,pre,samp { font-family:courier new,courier,monospace; }  
  15.     small { font-size:12px; }  
  16.     ul,ol { list-style:none; }  
  17.     a { text-decoration:none; }  
  18.     a:hover { text-decoration:underline; }  
  19.     sup { vertical-align:text-top; }  
  20.     sub { vertical-align:text-bottom; }  
  21.     legend { color:#000; }  
  22.     fieldset,img { border:0; }  
  23.     button,input,select,textarea{ font-size:100%; }  
  24.     table { border-collapse:collapse; border-spacing:0; }  
  25.   
  26.     .col-main{ float:left; width:100%; min-height:1px; }  
  27.     .col-sub,.col-extra { float:left; }  
  28.     .layout:after,.main-wrap:after,.col-sub:after,.col-extra:after { content:'\20'; display:block; height:0; clear:both; }  
  29.     .layout,.main-wrap,.col-sub,.col-extra { zoom:1; }  
  30.   
  31.     /* Common Features */  
  32.     .hidden { display:none; }  
  33.     .invisible { visibility:hidden; }  
  34.   
  35.     /* Remove Float */  
  36.     .clear { display:block; height:0; overflow:hidden; clear:both; }  
  37.     .clearfix:after { content:'\20'; display:block; height:0; clear:both; }  
  38.     .clearfix { *zoom:1; }  
  39.   
  40.     /* For non ie browsers also display the vertical scroll bar by default, to prevent the flicker caused by the scroll bar */  
  41.     html { overflow-y:scroll; }  
  42.   
  43.     /* Default link styles */  
  44.     a:link {color: #003399; }  
  45.     a:visited {color: #123689;}  
  46.     a:hover {color: #FF6600;}  
  47.     </style>  
  48. </head>  
  49. <body>  
  50.       
  51.     <style type="text/css">  
  52.         .menu { width:200px; border:1px solid #CCC; margin-bottom:20px }  
  53.         .menu h3 { height:30px; line-height:30px; background:#ccc; }  
  54.         .menu .num { font-weight:bold; color:red; padding-left:30px; }  
  55.     </style>  
  56.   
  57.     <div class="menu">  
  58.         <h3>系统设置 <span class="num"></span></h3>  
  59.         <ul>  
  60.             <li>菜单1</li>  
  61.             <li>菜单2</li>  
  62.             <li>菜单3</li>  
  63.             <li>菜单4</li>  
  64.             <li>菜单5</li>  
  65.             <li>菜单6</li>  
  66.         </ul>  
  67.     </div>  
  68.   
  69.     <div class="menu">  
  70.         <h3>菜单设置2 <span class="num"></span></h3>  
  71.         <ul>  
  72.             <li>菜单1</li>  
  73.             <li>菜单2</li>  
  74.             <li>菜单3</li>  
  75.   
  76.         </ul>  
  77.     </div>  
  78.   
  79.     <div class="menu">  
  80.         <h3>菜单设置3 <span class="num"></span></h3>  
  81.         <ul>  
  82.             <li>菜单1</li>  
  83.             <li>菜单2</li>  
  84.             <li>菜单3</li>  
  85.             <li>菜单4</li>  
  86.   
  87.             <li>菜单5</li>  
  88.         </ul>  
  89.     </div>  
  90.   
  91.   
  92.     <script type="text/javascript" src="jquery.js"></script>  
  93.     <script type="text/javascript">  
  94.         for ( var i=0; i<$('.menu').length; i++){  
  95.             var num = $('.menu').eq(i).children('ul').children('li').length;  
  96.             $('.menu').eq(i).find('.num').text(num);  
  97.         }  
  98.     </script>  
  99.   
  100.       
  101. </body>  
  102. </html>  

图标图像: 

  • HTML5
  • HTML5
  • 开发人员
  • 学生

  • Viewing all articles
    Browse latest Browse all 663


    <script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>