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 Posts

How to Hide a Divi Module When Scrolling Up or Down

In this quick tutorial, I’ll show you how to hide a Divi module when scrolling in a specific direction (up or down), so that the module only shows when you want it to. This is especially useful when using Divi’s Scroll Effects feature and you have a effect you want to...

Fade a Divi Image Module Edge into the Background

Want to create a stylish fade effect on your Divi image module—where one side fades smoothly into the background? With a bit of CSS, you can make any edge (or corner) of the image fade out: top, bottom, left, right, or even diagonally.Fade a Divi Image Module Edge...

Hide the Header and Footer in the Hello Elementor Theme

Removing the default header and footer from your Hello Elementor theme allows for a streamlined and distraction-free website design. This is especially useful when creating unique landing pages, full-width layouts, or custom headers and footers with a page builder. In...

Setting up the Divi Password Box Module

Setting up password protection on a page can help you control access to sensitive or private content in WordPress, allowing only authorized visitors to view certain sections. With the Divi Password Box module, you can replace the plain Divi password form with a fully...

Open Divi Social Media Icons in a New Tab

Ensuring your website's social media icons open in a new browser tab creates a seamless user experience and keeps visitors engaged with your site while allowing them to explore your social media presence. This approach prevents users from navigating away from your...

Random Posts