Home  >  Article  >  Web Front-end  >  如何让2个不同的a标签点击时显示不同颜色_html/css_WEB-ITnose

如何让2个不同的a标签点击时显示不同颜色_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-21 09:14:292078browse

例如这个 怎么使这两个变成不同的色
用css来解决


回复讨论(解决方案)

nbsp;html>



页面名称



0000001
0000002


<!DOCTYPE html><html><head lang="en">    <meta charset="UTF-8">    <title></title>    <script src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script></head><body><a href="javascript:void(0)" onclick="changecolor(this,'#cccccc')">第一个颜色</a><a href="javascript:void(0)" onclick="changecolor(this,'#00ff00')">第二个颜色</a></body><script>    function changecolor(obj,colors){        $(obj).css({"color":colors});    }</script></html>

试试看

每个a 加个类,单独定义颜色就可以,同2楼……

把a标记加多一个class,两个就两个不同的class,然后在style里面写鼠标行为a:hour,a:link什么的就行了

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