TwelvestoneFront End

jquery not triggering ... needs second click


Sign in

  • Waiting for Godot ( 730 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 5.1 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.9 k posts )
    general front end design an...
  • Back End ( 9.7 k posts )
    serverside scripting, progr...
  • Projects and Theory ( 12 k posts )
    This forum is for discussio...
  • FAQ ( 269 posts )
    All those nagging questions...
  • Design ( 17 k posts )
    graphics & all aspects of g...
  • Purgatory ( 3.6 k posts )
    12stone Jail, feel free to ...
WingNut
 
2010-08-04

i have a div that i hide inline (display:none)

then i have a button to use jquery to fade that div in ... it works, except you have to click twice for it to fade in ... can anyone see what i need to change?? thanks

this is the function function accordionFader() { $('#hide').click(function() { $('#accordionWrapper').fadeOut('slow', function() { // Animation complete. }); }); $('#show').click(function() { $('#accordionWrapper').fadeIn('slow', function() { // Animation complete. }); }); }

here's the button that calls the function: SHOW

Stinky
 
2010-08-05

It's not triggering because the first click triggers the setting of the event. What you should do is match the element with the click event outside of the HTML.

Pull the code you have out of the accordionFader function and it'll work fine.

WingNut
 
2010-08-05

ah. thanks

Sorry, you must be a member to post to a conversation. Either log in or sign up to get involved.
TwelvestoneFront End

jquery not triggering ... needs second click