Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6900977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:36:56+00:00 2026-05-27T07:36:56+00:00

I have this HTML: #navcontainer ul { margin: 0; padding: 0; list-style-type: none; }

  • 0

I have this HTML:

#navcontainer ul {
    margin: 0;
    padding: 0;
    list-style-type: none;
}

#navcontainer li { margin: 0 0 .2em 0; }

#navcontainer a {
    padding-left: 4px; 
    font: bold 13px Verdana;
    display: block;
    color: #FFF;
    background-color: #036;
    width:35em;
    #padding: .2em .8em;
    text-decoration: none;
}

#navcontainer a:hover {
    background-color: #369;
    color: #FFF;
}
....
....
....
var po =null;
function loadNewVideo(id, startSeconds,o) { 
  c(o.id,"#FF3030");
  if(po!=null)
  {
    c(po.id,"#036");
  }
  po = o;
}

function c(id,c) {  
    document.getElementById(id).style.background = c;
}

.... 
....
....

<div id="navcontainer">
<ul>
<li><a href="javascript:void(0);" onclick="loadNewVideo('xxxx1','0');" id="l_0">Blah 1</a></li>
<li><a href="javascript:void(0);" onclick="loadNewVideo('xxxxx3','0');" id="l_1">Blah 1</a></li>
<li><a href="javascript:void(0);" onclick="loadNewVideo('xxxxx4','0');" id="l_2">TBlah 2</a></li>
<li><a href="javascript:void(0);" onclick="loadNewVideo('xxxxx5','0');" id="l_3">Blah 3</a></li>
</ul> 
</div>

Now when I haven’t clicked a link, the a:hover is working fine; but after I click one of the links, the a:hover in the clicked link stops working. Why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:36:57+00:00Added an answer on May 27, 2026 at 7:36 am

    Using !important

    If you want the :hover to override your inline styling, use !important.

    #navcontainer a:hover {
       background-color: #369 !important;
       color: #FFF;
    }
    

    Won’t work in some versions of IE though.


    Using a class

    Another option would be to apply a class instead of using inline styles. But you’d need to make sure the class is located before the :hover definition in your CSS.

    #navcontainer a.clicked {
        background-color: #FF3030
    }
    
    #navcontainer a:hover {
       background-color: #369;
       color: #FFF;
    }
    

    js

    function loadNewVideo(id, startSeconds, o) {
        c(o.id, "clicked");
        if (po != null) {
            c(po.id, "#036");
        }
        po = o;
    
    }
    
    function c(id, c) {
        var el = document.getElementById(id);
        if( (" " + el.className + " ").indexOf(" " + c + " ") === -1 ) {
            el.className += " " + c;
        }
    }
    

    Side note

    You’re missing an argument in your inline handlers:

                           <!-- need to pass this as the third argument -->
    <li><a href="javascript:void(0);" onclick="loadNewVideo('xxxx1','0', this);" id="l_0">Blah 1</a></li>
    

    And you really don’t need to pass its id, and then use getElementById in the c function. Just pass the element itself:

    c(o, "clicked");
    

    …and use it directly:

    function c( el, c ) {
        if( (" " + el.className + " ").indexOf(" " + c + " ") === -1 ) {
            el.className += " " + c;
        }
    }
    

    JSFIDDLE DEMOS of both approaches

    • First approach

    • Second approach

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this HTML with a table: <div class=currentDesignDiv style=margin-bottom:5px;> <div> <img alt=Thumbnail src=http://www.propertyware.com/templates/
I have this HTML code for radios: <input type='radio' name='a_27' value='Yes' id='a_27_0' /> <input
I have this HTML dropdown: <form> <input type=text id=realtxt onkeyup=searchSel()> <select id=select name=basic-combo size=1>
i have this html <ul> <li><form action=# name=formName></li> <li><input type=text name=someName /></li> <li><input type=text
I have this html structure: <div id=home> <div class=section_header> <h1 class=left data-target=newest><?=lang('home_newest');?></h1> ... </div>
I have this html code: <tr> <td><label><input type=text name=id class=DEPENDS ON info BEING student
I have this HTML/PHP <input name=add to list class='fncAdd' id='moodal_close' value=add to list onclick=cajaxUpdateCartProduct('<?=
I have this HTML code: <body> <div id=div0 style=display:inline; background-color:green; width:100%> <div id=div1 style=display:inline;
I have this HTML: <input type=text name=textField /> <input type=submit value=send /> How can
I have this HTML/CSS code ( JSBin ): .trackTime{width:50px; text-align:left; float:left;} .trackInputTime{width:45px; height:22px; background-color:#F4F4F4;}

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.