Solution:
jQuery('.card-header') .closest(".w-100") .each(function() { e = jQuery(this); e.attr('id', e.attr('id').replace(/ /g,'-')); });