# Open a Divi Toggle or Accordion From the URL

> Opens the Divi toggle or accordion item whose CSS ID matches the address hash (for example #shipping) and scrolls to it, so you can link straight to an answer.

- Type: HTML
- Runs: Site-wide footer
- Category: [Page Builders & Themes](https://wpide.com/library/category/page-builders/)
- Tags: divi, accordion, toggle, links
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/divi-open-toggle-from-hash/

## Code

```html
<script>
(function () {
    function openTarget() {
        var id = decodeURIComponent(window.location.hash.slice(1));
        if (!id) { return; }
        var target = document.getElementById(id);
        var toggle = target && (target.classList.contains('et_pb_toggle') ? target : target.querySelector('.et_pb_toggle'));
        if (!toggle) { return; }
        if (toggle.classList.contains('et_pb_toggle_close')) {
            var title = toggle.querySelector('.et_pb_toggle_title');
            if (title) { title.click(); }
        }
        setTimeout(function () { toggle.scrollIntoView({ block: 'start', behavior: 'smooth' }); }, 300);
    }
    window.addEventListener('load', openTarget);
    window.addEventListener('hashchange', openTarget);
})();
</script>
```

## Notes

Give the toggle or accordion item a CSS ID in its Advanced tab, then link to page-url#that-id.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Open a Divi Toggle or Accordion From the URL" in its snippet library and add it in one click; or create a new HTML snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
