MEM
MEM

Reputation: 31347

can't get jquery toggle here - logic help needed

The point is to toggle some fieldsets but, depending on the scenario you may have either one or two fieldsets active. This should work on both cases.

http://jsfiddle.net/4XQ2u/18/

This works only if we have one fieldset appearing.

If you duplicate the fieldsets and test it again, you will notice that, if we have two fieldsets, the links that trigger should also change, but they don't, making the link text to be absurd.

http://jsfiddle.net/4XQ2u/40/

Am I using the wrong tool for this job, or is it a logic issue on this code ?

Upvotes: 0

Views: 49

Answers (2)

Richard Parnaby-King
Richard Parnaby-King

Reputation: 14882

The code is listening for someone to click on the button before it does anything. The simplest solution is to add an if statement at the bottom of your code:

if($('#localized fieldset').length > 1)
{
  $(".trigger").toggle();
}

Upvotes: 1

Chris Dixon
Chris Dixon

Reputation: 9167

Do you mean something like this?

http://jsfiddle.net/4XQ2u/44/

Upvotes: 0

Related Questions