43 posts
  • Has sold $1+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Located in United Kingdom
  • Sells items exclusively on Envato Market
+1 more
Renny says

Im having trouble making it so once a link in the nav has been clicked it closes the menu (yes i know there are scripts out there that can do it all, and bootstrap has it all) but i just want a simple little script that does two things.

I managed to do it once before but ive since lost my snippet due to my computer failing and saldy it isnt in my dropbox.

jQuery(document).ready(function($) { $(".ToggleMenu").click(function() { $("nav").slideToggle(500); }); });

Never been good with jquery, could anyone help me?

thank you in advance Tom

1177 posts
  • Has been part of the Envato Community for over 4 years
  • Has sold $40,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 50+ items on Envato Market
+5 more
Smartik says

Show the HTML source as well. Or better create a Fiddle. :)

1051 posts
  • Has sold $5,000+ on Envato Market
  • Located in United Kingdom
  • Has been a beta tester for an Envato feature
  • Helped several times protecting Envato Market against copyright violations
+5 more
Alexlasek says

there is no way to help you, if we can’t see the code. Upload that bit into http://codepen.io/ with html and css then I will help you, otherwise it’s nearly impossible ;/

cheers

43 posts
  • Has sold $1+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Located in United Kingdom
  • Sells items exclusively on Envato Market
+1 more
Renny says

I’m sorry, I thought id put all the relevant coded needed.

http://jsfiddle.net/rG92z/

Ignore the fact the button to open jumps down in the fiddle. The problem im having is getting the menu to close once a menu link has been clicked on

Tom

650 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Provided great contribution to our forums
  • Has been a beta tester for an Envato feature
+4 more
Gareth_Gillman says

Hi Renny

hows this look? jsfiddle.net/rG92z/1/

1051 posts
  • Has sold $5,000+ on Envato Market
  • Located in United Kingdom
  • Has been a beta tester for an Envato feature
  • Helped several times protecting Envato Market against copyright violations
+5 more
Alexlasek says

I’m sorry, I thought id put all the relevant coded needed. http://jsfiddle.net/rG92z/

Ignore the fact the button to open jumps down in the fiddle. The problem im having is getting the menu to close once a menu link has been clicked on

Tom
jQuery(document).ready(function($) { $(".ToggleMenu").click(function() { $("nav").slideToggle(500); }); $("nav a").click(function(){ $("nav").slideToggle(500); }); });

EDIT: sorry Gareth_Gillman, haven’t seen yours. cheers

43 posts
  • Has sold $1+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Located in United Kingdom
  • Sells items exclusively on Envato Market
+1 more
Renny says

Hi Renny hows this look? jsfiddle.net/rG92z/1/


I’m sorry, I thought id put all the relevant coded needed. http://jsfiddle.net/rG92z/

Ignore the fact the button to open jumps down in the fiddle. The problem im having is getting the menu to close once a menu link has been clicked on

Tom
jQuery(document).ready(function($) { $(".ToggleMenu").click(function() { $("nav").slideToggle(500); }); $("nav a").click(function(){ $("nav").slideToggle(500); }); }); EDIT: sorry Gareth_Gillman, haven’t seen yours. cheers

They both work perfectly! thank you very much for your help!

edit: is there a way to make a jquery run only in mobile/tablets?

650 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Provided great contribution to our forums
  • Has been a beta tester for an Envato feature
+4 more
Gareth_Gillman says

Have a read of this for mobiles and jQuery

by
by
by
by
by
by