JQuery addClass question?

The code you have works fine for me. I've pasted a complete page, which I used to test.

The code you have works fine for me. I've pasted a complete page, which I used to test. Untitled Duurzaam B-to-B Healthcare Dienstverlening ADFSDFSDF IUYIUYIU CVCBVCV MNBBMNBMB ADFSDFSDF IUYIUYIU CVCBVCV MNBBMNBMB I'm not sure what you're trying to do, but you might want to add a $('span.

Branche'). RemoveClass('active') at the beginning so that the "active" class is switched to the selected span, rather than applied cumulatively.

1 Patrick, thank you very much in advance! This code works perfectly for me too... standalone. I even added some extra span's to check it so my span class numbers now are 1,1,1,1,1,2,3,4,2.

But in the code of the website I'm building it still doesn't work. I have one $(document). Ready function which has this code amongst others.

– tvgemert Jul 9 '09 at 14:01.

I'd simplify it somewhat: Duurzaam B-to-B Healthcare Dienstverlening ADFSDFSDF IUYIUYIU CVCBVCV MNBBMNBMB which simplifies your Javascript considerably: $("#branchNav > a"). Click(function() { $("span. B" + this.Id).

AddClass('active"); }); No point doing string manipulation when you don't have to. Try to keep your code as simple as possible especially if a relatively minor markup change makes it just that much more readable.

Thanks, but it should add class to multiple span elements with same classname. It's not very neat to have more than one id with same name. – tvgemert Jul 9 '09 at 13:48 Easily modified.Edited.

– cletus Jul 9 '09 at 13:50.

You shouldn't have to do this, but try this to see if it works: $("span. Branche" + sId). Each(function() { $(this).

AddClass("active"); }).

It's possible, but it would be very strange. – usoban Jul 9 '09 at 13:53 I tried, but same result as original. – tvgemert Jul 9 '09 at 14:05 My bad, the code is perfect like this but my css wasn't right for the other three classes.

I stared myself blind on this because the first tab functioned. Thanks all for your efforts it really helped a lot. – tvgemert Jul 9 '09 at 14:21.

I think only problem is in ADFSDFSDF IUYIUYIU CVCBVCV MNBBMNBMB section , where class="branche1" repeted 3 times and I Have only modified this part : ADFSDFSDF IUYIUYIU CVCBVCV MNBBMNBMB only and its working fine .

– tvgemert Jul 9 '09 at 13:49 classes can be repeated, nothing wrong with that – Ben Scheirman Jul 9 '09 at 13:50 1 "This works for me only for the first element (1). The rest gives no result (also no error)" and class="branche1" repeated 3 times so , only takes effect by this code $('span. Branche'+sId).

AddClass('active'); – Sujoy Jul 9 '09 at 13:58.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions