With my JavaScript I have set .active after a name of a li when touched on it.

Now I am running into problems with this when I want to change the style of it. How can I change the style span then when touched?

this is normal: ".tab1 span"

this is active: ".tab1.active span"

i do with the span thing:


so by using a custom id for each span. Now, how do i do this like with an if statement which is constantly refreshing or so, i dunno, at least something that notices that when .active span style should be changed.

JavaScript file: http://tb.gdscei.com/javascript/tabbar.js

Website: http://tb.gdscei.com


  • I added iphone and webkit labels as well as formatted your question a bit... honestly, you might get more help on StackOverflow.com Mottie almost 9 years ago

1 answer

Mottie 1134

First off your code only seems to work for iphone/webkit browsers so I can't be of much help there.

But, just from a quick glance of your code you need to use a double equal sign for comparison (in tabbar.js):

} else if (c = 2) {

should be:

} else if (c == 2) {


Also, your three tabs are designed to fit across the screen, but for me the three together are too wide, so the third button ends up on the next line so you might want to subtract out some padding.

Answered almost 9 years ago by Mottie