Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #1068690

    uberphoto
    Participant

    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.

    #1068695

    uberphoto
    Participant

    Your 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!

    #1068726

    uberphoto
    Participant

    Lol! 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.

    #1069104

    Rad
    Moderator

    Hi 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!

    #1069876

    uberphoto
    Participant

    Thanks — 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. 🙂

    #1070127

    Rue Nel
    Moderator

    You’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.