Click a Divi Content Toggle Module by a Link

Boost Your Site and Save 20% this Weekend

Join 50,000 users and build a better site with 20% off all Divi Booster plugins.

Discount applied at checkout. Offer ends Monday!

Day(s)

:

Hour(s)

:

Minute(s)

:

Second(s)

The Divi Content Toggle Module 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 when Linking to the Page */
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

This post may contain referral links which may earn a commission for this site

Divi Booster

Hundreds of new features for Divi
in one easy-to-use plugin

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

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