Generate dynamic ID’s for each accordion button

I was able to solve this problem with using the jQuery closest method.I had to nest the button inside the container so the function would be able to return the first ancestor of that particular button element that is clicked.

$(".toggle-button").on("click", function() {
  $(this).closest('.collapse-group').find('.wpsm_panel-collapse').collapse('toggle');
});