Javascript 如何获取链接以保持活动状态?

Javascript 如何获取链接以保持活动状态?,javascript,html,hyperlink,Javascript,Html,Hyperlink,我正在制作一个网站,上面有一个关于。讲座分为几章。每一章都有自己的链接,当点击一个新视频时,会加载一个外部html,并加载到一个文本窗口中。我需要这些链接保持活跃,以便ppl知道它们在哪一章 以下是我当前的html: <li><a href="#" onclick="javascript:loadContent('#pres', chapter1.html');changeVideo('chapter1')">chapter1</a></li> &

我正在制作一个网站,上面有一个关于。讲座分为几章。每一章都有自己的链接,当点击一个新视频时,会加载一个外部html,并加载到一个文本窗口中。我需要这些链接保持活跃,以便ppl知道它们在哪一章

以下是我当前的html:

<li><a href="#" onclick="javascript:loadContent('#pres', chapter1.html');changeVideo('chapter1')">chapter1</a></li>
<li><a href="#" onclick="javascript:loadContent('#pres', 'chapter2.html');changeVideo('chapter2')">chapter2</a></li>
这不管用。我也尝试过删除除addClass函数以外的所有函数,但没有成功

有什么想法吗

你可以试试这个

首先创建一个级联样式表(CSS),并在其中编写如下代码:

a:active {
    color: #006600;
    font: 12px Verdana, Arial, Helvetica, San-serif;
    text-decoration: none;
}

然后将此代码粘贴到html页面的头部:

 <link type="text/css" href="<Path of the CSS>.css" rel="stylesheet"/>

你可以试试这个

首先创建一个级联样式表(CSS),并在其中编写如下代码:

a:active {
    color: #006600;
    font: 12px Verdana, Arial, Helvetica, San-serif;
    text-decoration: none;
}

然后将此代码粘贴到html页面的头部:

 <link type="text/css" href="<Path of the CSS>.css" rel="stylesheet"/>

功能点击章节(类型、页面、章节){
加载内容(类型、页面);
更改视频(第章);
removeAllClass();
addClass(document.getElementById('id_'+章));
}
函数removeAllClass(){
var aAnchor=document.getElementsByTagName('A');
对于(var i=0;i
  • 功能点击章节(类型、页面、章节){
    加载内容(类型、页面);
    更改视频(第章);
    removeAllClass();
    addClass(document.getElementById('id_'+章));
    }
    函数removeAllClass(){
    var aAnchor=document.getElementsByTagName('A');
    对于(var i=0;i
    

  • 您是否也设置了
    活动的
    类的css?A类
    。活动的
    和伪类
    :活动的
    是不一样的。我确实,确实拼错了,但这无助于纠正这一点。您是否也设置了
    活动的
    类?A类
    活动的
    和伪类
    :活动的
    的csse不一样。我确实,确实拼错了,但这无助于纠正这个错误。
    
     <link type="text/css" href="<Path of the CSS>.css" rel="stylesheet"/>
    
    function clickChapter(type, page, chapter){
        loadContent(type, page);
        changeVideo(chapter);
        removeAllClass();
        addClass(ocument.getElementById('id_'+chapter));
    }
    
    function removeAllClass(){
        var aAnchor = document.getElementsByTagName('A');
        for(var i=0; i<aAnchor.length;  i++){
            aAnchor[i].className = '';
        }
    }
    
    <li><a href="#" id="id_chapter1" onclick="clickChapter('#pres', 'chapter1.html', 'chapter1')">chapter1</a></li>
    <li><a href="#" id="id_chapter2" onclick="clickChapter('#pres', 'chapter2.html', 'chapter2')">chapter2</a></li>