Skip to content Skip to sidebar Skip to footer

Jquery - Different Function On Second Click

I'm trying to create a curtain Opening & Closing effect. But for some reason I can't make my curtains close once they're opened. Here's what I have so far: http://jsfiddle.net

Solution 1:

Change

if ($('.curtain').attr('rel', 'open')){

to

if ($('.curtain').attr('rel') == 'open') {

And do the same for the second if statement. The .attr(name, value) will always set the attribute to the specified value, whereas .attr(name) will simply return the value

Updated Fiddle

Post a Comment for "Jquery - Different Function On Second Click"