July 26, 201115 yr Hi guys, I am using a query slide bar in a site I am working on. I am able to make the bar slide up and appear by using a click function. However I can not figure out how to make it click and disappear? To be honest I do not even know if I am doing it the right way? it has been more of a trail and error thing for me. So below is the script: $(document).ready(function(){ //To switch directions up/down and left/right just place a "-" in front of the top/left attribute //Caption Sliding (Partially Hidden to Visible) $('.boxgrid.captionMain').click(function(){ $(".cover", this).stop().animate({top:'280px'},{queue:false,du ration:750}); }, function() { $(".cover", this).stop().animate({top:'530px'},{queue:false,du ration:750}); }); }); note: If I change the .click function to hover, it goes up and down perfectly. I just want it to go up down with a click instead of a hover. Thanks in advance
July 26, 201115 yr Hi guys, I am using a query slide bar in a site I am working on. I am able to make the bar slide up and appear by using a click function. However I can not figure out how to make it click and disappear? To be honest I do not even know if I am doing it the right way? it has been more of a trail and error thing for me. So below is the script: $(document).ready(function(){ //To switch directions up/down and left/right just place a "-" in front of the top/left attribute //Caption Sliding (Partially Hidden to Visible) $('.boxgrid.captionMain').click(function(){ $(".cover", this).stop().animate({top:'280px'},{queue:false,du ration:750}); }, function() { $(".cover", this).stop().animate({top:'530px'},{queue:false,du ration:750}); }); }); note: If I change the .click function to hover, it goes up and down perfectly. I just want it to go up down with a click instead of a hover. Thanks in advance probably make your life easyer to use the jquery functions hide and show if you actually want to make it visible/hidden, these can be customised too, in your customisations i'd recomment you animate based on padding or margin instead of top. also when doing these sorts you tend to replace the control on animation... try summin like this if you wish to carry on with same method...; $('.boxgrid.captionMain').click( function() { if(this.hasClass("open")){ //close $(".cover", this).stop().animate({top:'280px'},{queue:false,du ration:750}); }else { //open $(".cover", this).stop().animate({top:'530px'},{queue:false,du ration:750}); } thsi.toggleClass("open"); )}; }); Edited July 26, 201115 yr by mikejonesey
July 27, 201115 yr Author probably make your life easyer to use the jquery functions hide and show if you actually want to make it visible/hidden, these can be customised too, in your customisations i'd recomment you animate based on padding or margin instead of top. also when doing these sorts you tend to replace the control on animation... try summin like this if you wish to carry on with same method...; $('.boxgrid.captionMain').click( function() { if(this.hasClass("open")){ //close $(".cover", this).stop().animate({top:'280px'},{queue:false,du ration:750}); }else { //open $(".cover", this).stop().animate({top:'530px'},{queue:false,du ration:750}); } thsi.toggleClass("open"); )}; }); Thanks for your reply, I did try your suggestion however, the slider now does not seem to move at all now. any other suggestions?
July 27, 201115 yr Author Here is a link to the website if you feel you need to see what I am talking about: http://sogabranding.com/about_us.html
July 27, 201115 yr Thanks for your reply, I did try your suggestion however, the slider now does not seem to move at all now. any other suggestions? Looks like he made a little typo in that code. thsi.toggleClass("open"); Should be: this.toggleClass("open");
Create an account or sign in to comment