Skip to content

Instantly share code, notes, and snippets.

@dannydickson
Last active August 23, 2017 20:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dannydickson/7a1668480f1f6e434bd229fc0866c16f to your computer and use it in GitHub Desktop.
Save dannydickson/7a1668480f1f6e434bd229fc0866c16f to your computer and use it in GitHub Desktop.
Add class to each sub-nav in Divi for separate styling. (add this code to Divi > Theme Options > Integrations > Body scripts. This will add a class to each individual sub nav (ie "sub-nav-1", "sub-nav-2" and so on). These new classes can now be styled individually to target the border-color, or anything else you want.
<script type="text/javascript">
jQuery(document).ready(function($) {
$( ".menu-item-has-children .sub-menu" ).addClass(function( index ) {
return "sub-nav-" + index;
});
})
</script>
.nav li ul.sub-menu-1,
.nav li ul.sub-menu-4 {border-color: red;}
.nav li ul.sub-menu-2,
.nav li ul.sub-menu-5 {border-color: blue;}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment