Click a Divi Content Toggle Module by a Link

Written by Dan Mossop

The Divi Content Toggle Module by Divi Extended lets you create toggle buttons for pricing tables, allowing users to easily switch between different pricing options. Normally the user needs to click on the toggle button to switch between the pricing tables. If you'd like to be able to have users follow a link to the "clicked" view of the Divi Content Toggle Module, here's how to do it.

Toggle a Divi Content Toggle Module by Link using jQuery

First, give your Content Toggle Module a CSS ID, such as "mytoggle" at:

Content Toggle Settings > Advanced > CSS ID & Classes > CSS ID

Then add the following jQuery code to your site: 

<script>
/* Open a Divi Content Toggle Module by Divi Extended when Linking to the Page */
/* Src: https://divibooster.com/toggle-a-divi-content-toggle-by-a-link/ */
jQuery(function($) {
	setTimeout(function(){
		var query = window.location.search.substring(1);
		var params = query.split('&');
		var toggle_id = '';
		for (var i = 0; i < params.length; i++) {
			var param = params[i].split('=');
			if (param[0] !== undefined && param[1] !== undefined) {
				param[1] = decodeURIComponent(param[1]);
				if (param[0] === 'toggle' && /^[a-zA-Z0-9]+$/.test(param[1])) {
					toggle_id = param[1];
				}
			}
		}
		if (toggle_id !== '') {
			$('#'+toggle_id+'.dipl_content_toggle .dipl_toggle_button .dipl_toggle_field').trigger('click');
		}
	}, 100);
});
</script>

Now you'll be able to trigger a click on the toggle when linking to the page containing it, by including a "toggle" parameter in the URL with the ID of your toggle. So, for example, your link to the page might look something like this:

https://divibooster.com/some-page/?toggle=mytoggle

Unlock Dynamic Content with Divi Booster

Elevate your site's customization capabilities with the Divi Booster plugin. Featuring hundreds of upgrades to help you create engaging, feature-rich websites effortlessly. Perfect for taking your Divi projects to the next level.

About Dan Mossop

Dan is a Scottish-born web developer, now living in Brisbane with his wife and son. He has been sharing tips and helping users with Divi since 2014. He created Divi Booster, the first Divi plugin, and continues to develop it along with 20+ other Divi plugins. Dan has a PhD in Computer Science, a background in web security and likes a lot of stuff, 

2 Comments

  1. Super helpful when dealing with dozens of FAQs. Have an index with questions on the top of the page, with jumplinks to the question and answer in the toggle modules below. Great for user experience and keeping things tidy.

    Reply
    • I'm glad it's proving helpful, Asad. Thanks for the feedback – much appreciated!

      Reply

Submit a Comment

Comments are manually moderated and approved at the time they are answered. A preview is shown while pending but may disappear if your are cookies cleared - don't worry though, the comment is still in the queue.

Your email address will not be published. Required fields are marked *.

We may earn a commission when you visit links on our website.

Latest From Divi Booster

How to Add the Post Status in Divi's Dynamic Content

Divi's Dynamic Content feature is great for enhancing your post/page templates with post-specific information. While Divi includes an option to show information such as the Post Created Date using Dynamic Content, there is no equivalent option for the Post Status....

Fix Divi Text Module "Regular" Font Weight Not Working

Are you encountering an issue where the font weights in Divi's Text Module don't seem to apply as expected? In particular, you might find that when you set the text module's body text font weight to "Regular", your font is actually assigned a weight of 500 instead of...

Make the Divi Gallery Module Swipeable

The Divi Gallery Module comes with a slider mode that lets you display images in a slider with clickable left/right arrows to scroll through the images. For mobile / touchscreen users, you can improve the user experience by allowing your user to swipe to navigate to...

How to Use Divi Dynamic Content in Woo Modules Product Selector

Divi's Dynamic Content is a powerful feature that lets you populate your Divi modules and theme builder templates with data pulled in various sources, such as custom fields. This allows for efficient organization and maintenance of your sites.Unfortunately, Divi's...

Random Divi Posts