Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1269450

    crawfordandjohn
    Participant

    Hey guys,

    Trying to use Cornerstone buttons to toggle sections if pressed, but it doesn’t want to work for me on the site. I currently have it working here >>> http://jsfiddle.net/crawfordandjohn/uvj5twse/ <<< with the same code I’m using on the site, but in Cornerstone it doesn’t want to work…

    https://www.v1cigs.co.uk/guides/

    CURRENT JAVASCRIPT

    $('.show-area-button-b').click( function() {
        $(".beginner").toggleClass("show-area");
    } );
    
    $('.show-area-button-i').click( function() {
        $(".intermediate").toggleClass("show-area");
    } );
    
    $('.show-area-button-a').click( function() {
        $(".advanced").toggleClass("show-area");
    } );
    

    I also tried adapting the JQuery you gave here – https://community.theme.co/forums/topic/js-button-to-open-collapse-accordion/
    But I couldn’t get that to work either.

    Any suggestions would be great :).

    Thanks!

    #1269500

    Paul R
    Moderator

    Hi,

    Kindly change your code to this.

    
    jQuery(function($) {
        $('.show-area-button-b').click( function() {
            $(".beginner").toggleClass("show-area");
        } );
    
       $('.show-area-button-i').click( function() {
            $(".intermediate").toggleClass("show-area");
       } );
    
      $('.show-area-button-a').click( function() {
            $(".advanced").toggleClass("show-area");
       } );
    });
    

    Hope that helps.

    #1269653

    crawfordandjohn
    Participant

    Amazing, thank you!

    Just a quick question, what do we need to add to ‘un’toggle one button when we click another?

    Thanks 🙂

    #1269668

    Rupok
    Member

    Hi there,

    In that case you can try like this :

    jQuery(function($) {
        $('.show-area-button-b').click( function() {
            $(".beginner").toggleClass("show-area");
            $(".intermediate, .advanced").removeClass("show-area");
        } );
    
       $('.show-area-button-i').click( function() {
            $(".intermediate").toggleClass("show-area");
            $(".beginner, .advanced").removeClass("show-area");
       } );
    
      $('.show-area-button-a').click( function() {
            $(".advanced").toggleClass("show-area");
            $(".beginner, .intermediate").removeClass("show-area");
       } );
    });

    Hope this helps.