Bug Tracker

Opened 11 years ago

Closed 11 years ago

#8524 closed bug (invalid)

When using toggle(), my DIV tag shows then hides again

Reported by: anonymous Owned by: anonymous
Priority: low Milestone: 1.next
Component: effects Version: 1.5.1
Keywords: Cc:
Blocked by: Blocking:


This is the jQuery code I'm using:

var flip = 0; $(".toggle").click(function() { $(".instructions").toggle( flip++ % 2 == 0 ); });

where the class name "toggle" belongs to an <a> element, and the class name "instructions" belongs to a <div> tag. The display property of the <div> tag is set to none.

Now, when I click on the <a> element, the <div> tag appears, then instantly disappears.

Change History (4)

comment:1 Changed 11 years ago by anonymous

I borrowed the code from one of the examples in the documentation. The example worked.

Oh, and I am using Firefox 4.0RC1.

comment:2 Changed 11 years ago by anonymous

I found a workaround: Add href="#" to the <a> tag.

comment:3 Changed 11 years ago by Rick Waldron

Component: unfiledeffects
Owner: set to anonymous
Status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a reduced jsFiddle test case to help us assess your ticket!

Additionally, test against the jQuery Edge version to ensure the issue still exists.

comment:4 Changed 11 years ago by addyosmani

Priority: undecidedlow
Resolution: invalid
Status: pendingclosed

The reason the original example described by the OP wasn't working is that they neglected to include a valid href in their a tag. The example in our docs uses button elements instead and didn't require it, so I think it's as simple as it being a minor coding error on their part. The rest of the behavior with toggle() is working absolutely fine.

Note: See TracTickets for help on using tickets.