我设置了以下脚本:
<script type="text/javascript">
var currentLink = null;
function changeLinkColor(link){
if(currentLink!=null){
currentLink.style.color = link.style.color; //You may put any color you want
}
link.style.color = '#007DAD';
currentLink = link;
}
</script>
以下代码受到影响:
<div class="main-content">
<h2>General</h2>
<hr noshade class="main-content-hr" />
<a href="SD-XG100.html" target="myframe" class="main-content-a" onClick="changeLinkColor(this)">
<li class="main-content-list">
Cover
</li>
</a>
<a href="SD-XM140.html" target="myframe" class="main-content-a" onClick="changeLinkColor(this)">
<li class="main-content-list">
Diagram <p class="redalert">(Not Released)</p>
</li>
</a>
</div>
此刻,当点击时,文本会改变颜色(太棒了)但子元素不会受到影响(文字说&#34; Not Released&#34;。此文本在css中有颜色)。
我尝试切换&#34; li&#34;和&#34; a&#34;周围,那不起作用。应用父元素时,是否可以忽略红色警报样式?
有任何想法或建议吗?
谢谢