First I am checking if the clicked button parent has the same class of a given path, then if the path class matches the parent clicked button class, it should be adding a class to the path itself.
<ul>
<li class="modern">
<button>Ex 1</button>
</li>
<li class="classic">
<button>Ex 2</button>
</li>
<ul>
<svg>
<path class="modern"></path>
<path class="classic"></path>
</svg>
$("button").on("click", function() {
var periodClass = $(this).parent().attr("class");
$("svg path").each(function() {
$("svg path").not('.'+periodClass).removeClass("active");
$('svg path.'+periodClass).target.classList.add('active');
});
});
Also tried
$('svg path.'+periodClass).addClass('active');