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

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

WBOY
Release: 2016-06-13 12:21:11
Original
1412 people have browsed it

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

本帖最后由 mf0916 于 2015-06-02 18:49:22 编辑 我的HTML调用代码是这样的
<br />{loop $ad_types $u $v}<br /><a href="$u" target="_blank"><font color=在此改变偶数和奇数条的超链接的文字颜色交替">$v</font></a><br />{/loop}<br />
Copy after login

PHP的代码是
<br />$adlist = explode ("\n", str_replace ("\r", "", $ad));<br /> foreach($adlist as $url=>$value){<br />	$arr=explode('|',$value);<br />	$ad_types[$arr[0]]=$arr[1];       <br /> }<br />
Copy after login

需要调用循环的原始代码假如是
<br />http://www.csdn.net | 您好CSDN<br />http://www.google.com | 您好谷歌<br />http://www.baidu.com | 百度网<br />http://www.163.com | 网易<br />
Copy after login

求解决 在线等
------解决思路----------------------
JQuery
<style><br />A.even:link { COLOR: #0f6; TEXT-DECORATION: none }<br />A.even:visited { COLOR: #0f6; TEXT-DECORATION: none }<br />A.even:hover { COLOR: #0f6; TEXT-DECORATION: underline }<br />A.odd:link { COLOR: #000; TEXT-DECORATION: none }<br />A.odd:visited { COLOR: #000; TEXT-DECORATION: none }<br />A.odd:hover { COLOR: #f60; TEXT-DECORATION: none }<br /></style><br /><script src=scripts/jquery-1.8.3.min.js></script><br /><script><br />$(function() {<br />   $("a:even").addClass("even"); <br />   $("a:odd").addClass("odd"); <br />});<br /></script><br /><a href=http://www.csdn.net>您好CSDN</a><br><br /><a href=http://www.google.com>您好谷歌</a><br><br /><a href=http://www.baidu.com>百度网</a><br><br /><a href=http://www.163.com>网易</a><br>
Copy after login

------解决思路----------------------
你这个是什么标签模版?
大概思路是这样,如果你的模版有index,估计可以用index代替 $xx
<br />{php $xx=1}<br />{loop $ad_types $u $v}<br />{if $xx%2==1}<br /><a href="$u" target="_blank"><font color=#ff0000">$v</font></a><br />{else}<br /><a href="$u" target="_blank"><font color=#ffff00">$v</font></a><br />{/if}<br />{php $xx++}<br />{/loop}<br />
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template