-
AuthorPosts
-
July 1, 2016 at 1:23 pm #1068690
The error was that there were too many ) in the beginning of the script and, when that was resolved, it would say Uncaught TypeError: jQuery(…) is not a function, and when that was resolved, that the section.slidetoggle was not a function. And if I managed to resolve that in some way the section would not start hidden, nor would a button open only its targeted section.
July 1, 2016 at 1:26 pm #1068695Your last bit of code, combined with resolving the errors, worked a treat. This is what it looks like now:
jQuery(function($){ $(document).ready(function($){ $('.button-trigger').each(function(index){ var section = $( $(this).attr('href') ); section.slideToggle(0); $(this).on('touchend click',function(e){ e.preventDefault(); section.slideToggle('slow') $('html, body').animate({ scrollTop: section.offset().top-90 }, 700, 'swing'); }); }); }); });
Thanks much!
And have an awesome weekend!
July 1, 2016 at 2:03 pm #1068726Lol! Here I thought I was done… The (hopefully) last piece of this puzzle is how to allow more than one button to do call the same action. For example, if I want to add a close button to the hidden section, or if I need to use a mobile version of a button, but the section does not require a separate mobile version.
In both cases, the hidden section starts open instead of closed and behaves strangely.
July 1, 2016 at 8:10 pm #1069104Hi there,
If the close button is within the hidden section, then it’s not visible. And if you wish to hide a section on the first load, then add this code too,
jQuery ( '.inactive-section' ).slideToggle('slow');
Then simply add inactive-section to the section’s class that you wish to hide.
Thanks!
July 2, 2016 at 7:17 pm #1069876Thanks — that helped with the loading as open and whatnot. The close button worked in previous (non-id-using) versions of the code. IF it is going to be a thing, though, I don’t absolutely -need- to have one. 🙂
July 3, 2016 at 2:11 am #1070127You’re welcome! We’re happy to help you out.
If you need anything else we can help you with, don’t hesitate to open another thread. -
AuthorPosts