Home >Backend Development >PHP Tutorial >求PHP或者JS给调用的循环列表超链接文字换不同颜色

求PHP或者JS给调用的循环列表超链接文字换不同颜色

WBOY
WBOYOriginal
2016-06-23 13:33:261186browse

我的HTML调用代码是这样的

{loop $ad_types $u $v}<a href="$u" target="_blank"><font color=在此改变偶数和奇数条的超链接的文字颜色交替">$v</font></a>{/loop}

PHP的代码是
$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>









非常感谢  我使用了你的代码 达到了我想要的结果
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
Previous article:PHP收邮件receiveMailNext article:Laravel中创建Model