Tagged: cornerstone
-
AuthorPosts
-
November 24, 2016 at 6:49 am #1269450
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!
November 24, 2016 at 7:38 am #1269500Hi,
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.
November 24, 2016 at 10:08 am #1269653Amazing, thank you!
Just a quick question, what do we need to add to ‘un’toggle one button when we click another?
Thanks 🙂
November 24, 2016 at 10:29 am #1269668Hi 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.
-
AuthorPosts