All Collections
Divi Documentation
Customizing Divi
Updating URL In Address Bar When Anchor Links Are Used
Updating URL In Address Bar When Anchor Links Are Used

By default Divi does not add the anchor links to the URL in the browser address bar. You can fix it by applying the following small code.

Karen avatar
Written by Karen
Updated over a week ago

This tutorial uses the default Primary menu items with anchor links to show the anchor links on the browser address bar.

<script class="et_fb_ignore">
jQuery( document ).ready(function() {
jQuery('#top-menu a[href*="#"]').click(function(){
let hash = jQuery(this).attr('href').split('#')[1];
if (hash > 0){
window.location.hash = hash;
}
});
});
</script>


โ€‹

For the same, if you want it for other places, not for the primary menu, you can replace the selector in the jQuery #top-menu a to your choice CSS selector.

Or if you are looking for universal through any content then you can use this script:

<script class="et_fb_ignore">
jQuery( document ).ready(function() {
jQuery('a[href*="#"]').click(function(){
let hash = jQuery(this).attr('href');
if(hash != "#") {
setTimeout(function(){ location.hash = hash;},800);
}
});
});
</script>
Did this answer your question?