0
我想随机(选定列表的)改变我已完成并且工作良好的标题背景的颜色,使用这个JS:将随机css颜色更改为一个DIV的背景和另一个DIV的边框顶部颜色
var bgcolorlist=new Array("#ef5c20", "#a7dbca", "#c5e53f", "#ffad14")
$(".cbp-hsinner").css("background-color",bgcolorlist[Math.floor(Math.random()*bgcolorlist.length)]);
,但我想同样的随机颜色应用到这个的 '边框顶部颜色':
.cbp-hsmenu > li.cbp-hsitem-open > a:after {
top: 100%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-color: transparent;
border-top-color: #ef5c20;
border-width: 10px;
left: 50%;
margin-left: -10px;
}
HTML:
<nav class="cbp-hsmenu-wrapper" id="cbp-hsmenu-wrapper">
<div class="cbp-hsinner">
<div class="site-header__logo-alt"><a href="http://helloarchie.blue/"><img width="145" alt="Hello Archie" src="<?php echo theme_url('/img/HA-LOGO3.png'); ?>" /></a></div>
<ul class="cbp-hsmenu">
<li>
<a href="http://helloarchie.blue">Home</a>
</li>
<li>
<a href="#">Categories</a>
<ul class="cbp-hssubmenu">
<li><a href="http://helloarchie.blue/category/personal/"><span>Personal</span></a></li>
<li><a href="http://helloarchie.blue/category/monthly-updates/"><span>Monthly Updates</span></a></li>
<li><a href="http://helloarchie.blue/category/informative/"><span>Informative</span></a></li>
<li><a href="http://helloarchie.blue/category/reviews/"><span>Reviews</span></a></li>
<li><a href="http://helloarchie.blue/category/guides/"><span>Guides</span></a></li>
</ul>
</li>
<li>
<a href="http://helloarchie.blue/about">About</a>
</li>
<li>
<a href="#">Elsewhere</a>
<ul class="cbp-hssubmenu">
<li><a href="http://kaye.at/"><span>Portfolio</span></a></li>
<li><a href="http://kaye.at/baby/"><span>The Baby Project</span></a></li>
</ul>
</li>
</ul>
</div>
</nav>
标签这里经过
这可能吗?
[Access the css“:after”selector with jQuery](http://stackoverflow.com/questions/17788990/access-the-css-after-selector-with-jquery) – Markai 2014-11-21 11:54:21
什么是相关的HTML ? – 2014-11-21 12:00:33
对不起,用HTML更新。 – 2014-11-21 12:07:25