Onclick,打开/关闭类脚本不工作在Chrome或IE


Onclick & On/Off Class Script Not Working on Chrome or IE

我有一个包含两个iframe和一个简单导航栏的页面。单击导航栏中的链接以页面上的一个iframe为目标,并替换它的内容。我试图在iframe中突出显示当前选择的链接,但它似乎只适用于Firefox。你们能给点建议吗?谢谢。

可在www.serioussportstv.net/bigbrother.php查看全文

在head标签中:

<script type="text/javascript">
function offclass(id)
{document.getElementById(id).className = 'class_off';}
function onclass(id)
{document.getElementById(id).className = 'class_on';}
</script>
CSS:

#links a.class_on {
color:red;
}
a.class_off {
color:white;
}

导航栏链接(每个链接):

<a id="link1" class="class_off" href="/streams/bb/live2.php" target="player"        style="font-size:16;font-family:Arial;text-decoration:none;" onclick="onclass('link1'); offclass('link2'); offclass('link3'); offclass('link4'); offclass('link5'); offclass('link6'); offclass('link7');">Show</a>

尝试切换类。这样就足够了:

<script>$(document).ready(function(){  $("#link1").click(function(){    $("a").toggleClass("class_on");  }); }); </script>

祝你好运,希望这对你有用

您可以看到这里使用的方法:http://www.w3schools.com/jquery/tryit.asp?filename=tryjquery_html_toggleclass