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

Enable Automatic Looping for YouTube Videos in the Divi Video Module

Enabling automatic looping for YouTube videos in your Divi video module ensures that content plays seamlessly and continuously without interruption. This feature can enhance user engagement, highlight key information, or create dynamic visual effects on your website....

Hide Video Controls in Divi Video Module

Disabling YouTube video controls in the Divi Video Module helps create a seamless, distraction-free viewing experience for your site visitors. This approach is useful when you want full control over how your video content appears and is interacted with on the page, or...

Mute YouTube Videos by Default in the Divi Video Module

In the Divi Video Module, starting your YouTube videos muted by default can create a more user-friendly browsing experience on your webpage. It is particularly beneficial for reducing distractions, enhancing visitor engagement, and providing a seamless content preview...

Autoplay Videos in Divi Video Module

Enabling videos in your Divi video module to start playing automatically can enhance both the site's design and user engagement. To ensure full compatibility with browser requirements, such as Chrome's autoplay policy, it's often necessary to start your videos muted...

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

Random Divi Posts