网络营销电子商务研究中心

网络营销电子商务研究中心 (https://www.0058.net/index.php)
-   DedeCMS (https://www.0058.net/forumdisplay.php?f=71)
-   -   文档列表隔行变色,5行js控制,简单、高效 (https://www.0058.net/showthread.php?t=4721)

Sabina 2014-05-01 10:26 PM

文档列表隔行变色,5行js控制,简单、高效
 
1 Attachment(s)
实现方法:在文档页面模板的<head></head>中加入以下代码:
Code:



    <style>    
    .tr1{background-color:#F2F7D7; height:24px}    
    .tr2  {background-color:#FFFFFF; height:24px}    
    td { font-size:12px;}    
    </style>    
    <script>    
    function  colortd(ob)  {    
      obob=ob.rows;    
      for(var  i=0;i<ob.length;i++)  {    
        if(i%2)  ob(i).className="tr1";    
        else  ob(i).className="tr2";    
        }    
      }    
    </script>  

第二步修改body 标签为<body onLoad="colortd(list)">

第三步调用实例为:

Code:



    <table width="350px" border="0" cellpadding="1" cellspacing="1" align="center"  style="background:#ABC094;" id="list">    
     {dede:arclist limit='0,12' titlelen=80}    
      <tr><td>  <img src="ico.gif" width="13" height="13" align="absmiddle"> <a href="[field:arcurl/]">[field:title/]</a></td></tr>     
     {/dede:arclist}    
    </table>  

效果图如下:
http://www.0058.net/attachment.php?a...1&d=1398954379


All times are GMT +8. The time now is 04:10 AM.

Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.