Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. little problem changing css class with javascript

little problem changing css class with javascript

Scheduled Pinned Locked Moved Web Development
javascripthtmlcssregexarchitecture
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jszpila
    wrote on last edited by
    #1

    Hello everyone, I have a table set up to look like a box with 4 tabs. There are two classes of tabs, tabactive and tabinactive. tabactive has a white background, black border on the top, left, and right, and a white border on the bottom. tabinactive has a gray background, and a black border on all sides. The problem I'm having is that in Firefox when I click the link that activates the javascript function to change the class of the table cell/tab, the background color changes correctly but the bottom border change doesn't always stick. I'll get tabactive tabs with black bottom borders, and tabinactive cells with white bottom borders - everything else works fine. Oddly enough, this only seems to happen for the last 2 cells/tabs (see HTML below). Here's my CSS: .tabactive { border: solid 1px black; border-bottom: solid 1px white; background-color: #FFFFFF; text-align: center; padding: 0px; margin: 0px; } .tabinactive { border: solid 1px black; border-bottom: solid 1px black; background-color: #CCCCCC; text-align: center; padding: 0px; margin: 0px; } Here's my javascript: /* set visibility of divs and change bg color of tabs */ function TabClick(LinkName) { for (var x = 1; x < 5; x++) //only allows for 4 tabs right now { TabID = "Tab" + x //assign names w/ increment that match elements DivID = "Div" + x //i.e. Tab1, Div2, etc Tab = document.getElementById(TabID) //grab elements Div = document.getElementById(DivID) if (TabID != LinkName) //set style and vis of unselected tabs + divs { Tab.className = "tabinactive" Div.style.visibility = "collapse" Div.style.display = "none" } else //set style and vis of selected tabs + divs { Tab.className = "tabactive" Div.style.visibility = "visible" Div.style.display = '' }//end else }//end for }//end function Here's my HTML (note that this happens almost exclusively on Tab3 and Tab4):

    Tab1

    Tab2

    Tab3

    Tab4

    This is Div1.

    Thi

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups