jbwebdesign Posted April 4, 2011 Report Share Posted April 4, 2011 hello, i am working on a script that will show more information...... I can't figure out how to do on 2nd click function...... here is my code: $('.morebutton').click(function(){ $('#wrap').css('height','100%'); $('.togglecontent').toggle('slow', function(){ //this is even $('#wrap').css('height','200px'); }, function(){ //this is odd $('#wrap').css('height','200px'); }); }); What i am trying to do is make the "#wrap" go back to 200px; when the user clicks the ".morebutton" for the 2nd time. Any ideas on how to do this?? Quote Link to comment Share on other sites More sharing options...
falkencreative Posted April 4, 2011 Report Share Posted April 4, 2011 Have you tried this? $('.morebutton').click(function(){ $('.togglecontent').toggle('slow', function(){ //this is even $('#wrap').css('height','100%'); }, function(){ //this is odd $('#wrap').css('height','200px'); }); }); Quote Link to comment Share on other sites More sharing options...
jbwebdesign Posted April 4, 2011 Author Report Share Posted April 4, 2011 yes, it doesn't work. Quote Link to comment Share on other sites More sharing options...
jbwebdesign Posted April 4, 2011 Author Report Share Posted April 4, 2011 i'm running this code right now: $('.morebutton').click(function(){ $('#wrap').css('height','100%'); $('.togglecontent').toggle('slow'); }); But i need some way to change the css back to 200px; on the second click of the more button......any ideas? Quote Link to comment Share on other sites More sharing options...
falkencreative Posted April 4, 2011 Report Share Posted April 4, 2011 You could always set a variable that gets 1 added to it every time the click event is called. If the variable is even, set the height to one value, if it is odd, set it to something else. Or use the height() function to find the current height of #wrap, and set the height based on whether the current height is 200px or not. Quote Link to comment Share on other sites More sharing options...
jbwebdesign Posted April 4, 2011 Author Report Share Posted April 4, 2011 hmm, can you show me an example? Quote Link to comment Share on other sites More sharing options...
jbwebdesign Posted April 4, 2011 Author Report Share Posted April 4, 2011 Great idea! i got it to work using the following: var count = 0; //the click count begins $('.morebutton').click(function(){ count = count +1; if(count % 2 === 0){ $('#wrap').css('height','200px'); } else{ $('#wrap').css('height','100%'); } $('.togglecontent').toggle('slow'); }); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.