Maison > Article > développement back-end > 求PHP或者JS给调用的循环列表超链接文字换不同颜色
我的HTML调用代码是这样的
{loop $ad_types $u $v}<a href="$u" target="_blank"><font color=在此改变偶数和奇数条的超链接的文字颜色交替">$v</font></a>{/loop}
$adlist = explode ("\n", str_replace ("\r", "", $ad)); foreach($adlist as $url=>$value){ $arr=explode('|',$value); $ad_types[$arr[0]]=$arr[1]; }
http://www.csdn.net | 您好CSDNhttp://www.google.com | 您好谷歌http://www.baidu.com | 百度网http://www.163.com | 网易
JQuery
<style>A.even:link { COLOR: #0f6; TEXT-DECORATION: none }A.even:visited { COLOR: #0f6; TEXT-DECORATION: none }A.even:hover { COLOR: #0f6; TEXT-DECORATION: underline }A.odd:link { COLOR: #000; TEXT-DECORATION: none }A.odd:visited { COLOR: #000; TEXT-DECORATION: none }A.odd:hover { COLOR: #f60; TEXT-DECORATION: none }</style><script src=scripts/jquery-1.8.3.min.js></script><script>$(function() { $("a:even").addClass("even"); $("a:odd").addClass("odd"); });</script><a href=http://www.csdn.net>您好CSDN</a><br><a href=http://www.google.com>您好谷歌</a><br><a href=http://www.baidu.com>百度网</a><br><a href=http://www.163.com>网易</a><br>
你这个是什么标签模版?
大概思路是这样,如果你的模版有index,估计可以用index代替 $xx
{php $xx=1}{loop $ad_types $u $v}{if $xx%2==1}<a href="$u" target="_blank"><font color=#ff0000">$v</font></a>{else}<a href="$u" target="_blank"><font color=#ffff00">$v</font></a>{/if}{php $xx++}{/loop}
JQuery
<style>A.even:link { COLOR: #0f6; TEXT-DECORATION: none }A.even:visited { COLOR: #0f6; TEXT-DECORATION: none }A.even:hover { COLOR: #0f6; TEXT-DECORATION: underline }A.odd:link { COLOR: #000; TEXT-DECORATION: none }A.odd:visited { COLOR: #000; TEXT-DECORATION: none }A.odd:hover { COLOR: #f60; TEXT-DECORATION: none }</style><script src=scripts/jquery-1.8.3.min.js></script><script>$(function() { $("a:even").addClass("even"); $("a:odd").addClass("odd"); });</script><a href=http://www.csdn.net>您好CSDN</a><br><a href=http://www.google.com>您好谷歌</a><br><a href=http://www.baidu.com>百度网</a><br><a href=http://www.163.com>网易</a><br>