jquery - Class not overwriting with addClass -


I am using a jQuery addClass to add a class to a tab, so when it is clicked This square will change, so it is clear that the tab is highlighted.

My HTML

  & lt; Div id = "mainNav" & gt; & Lt; Ul & gt; & Lt; Li id = "linkbund" onclic = "nava ('the band')" & gt; Band & lt; / Li & gt; & Lt; Li id = "linkTheMusic" onclick = "navigation ('the music')" & gt; Music & lt; / Li & gt;  

My CSS

  #mainnav li {float: left; Margin-right: 5px; White color; Font-family: Tahoma; font-weight: bold; Padding: 10px 8px 0px 8px; Background: url ('../ images / transparent-65.png'); Height: 40px; Height: 25px! Important; Limit: 1px solid # 000; } #man Lee: Hover {float: left; Margin-right: 5px; White color; Font-family: Tahoma; font-weight: bold; Padding: 10px 8px 0px 8px; Background: # 660000; Height: 40px; Height: 25px! Important; Border: 1 px solid # 660000; } .MainNav selected (float: left; margin-right: 5px; white color; font-family: tahoma; fonts thickness: bold; padding: 10px 8px 0px 8px; background: # 660000; height: 40px; height: 25px! Important: Limit: 1px solid # 660000;}  

my javascript

  function nav (a) {$ ('#' + a) .show (); $ ('# Link' + a) .addClass ('mainNavSelected');}  

This works properly, I check the firebug and can see it That class = "menonave-selected" has been added, but the list element is of the new class that Firebug lists all class items for Menon, but all of them have been taken out. What am I missing to change the class of this element?

< / Div>

  .mainnove selected (float: left; margin-right: 5px; white color; font-family: Tahoma; The thickness of the fonts: bold; padding: 10px 8px 0px 8px; background: # 660000; important; height: 40px; height: 25px! Important; border: 1 px solid # 660000! Important; }  

This should correct the problem. You are more specific to your CSS selector for #mainnav li by .mainNavSelected Due to #mainnav li will always show your style before .mainNav.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -