I've got a div that will swap the position of the class name depending on where it is on the page. I'm trying to strip the header-section- text and header-type text so I just have payment or resource. But depending on where the class is I will sometimes get a space before or after the header-type class. In order to do this I'm calling .replace() 3 times there has to be a better more concise way of doing this instead of having three .replace methods. Any ideas?
<div class="header-section-payment header-type"></div>
<div class="header-type header-section-resource"></div>
JQUERY
var headerCategory = $(this).closest('div[class*="header-section-"]')
.attr('class')
.replace('header-section-', '')
.replace(' header-type', '')
.replace('header-type ', '');
I learn best by code samples so please include where applicable. Thanks!
trimfunction, docs here.removeClassexistence.