We have several CSS classes with the following pattern below. They all start with either bg-- or color--. How can I check if an element contains the CSS class substring using jQuery and if found then remove it?
Examples:
bg--whitebg--redbg--orangecolor--orangecolor--redcolor--purple
What I tried
$(function() {
var divEl = $('div');
if(divEl.hasClass('*=bkg--') {
divEl.removeClass('*=bkg--');
}
if(divEl.hasClass('*=color--') {
divEl.removeClass('*=color--');
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="bkg--red color--white">Holisticly build resource sucking methodologies before distributed methodologies. </div>
<div class="bkg--orange color--white">Phosfluorescently integrate revolutionary collaboration and idea-sharing through efficient services.</div>
<div class="bkg--purple color--purple">Credibly maximize impactful e-tailers with resource-leveling convergence. </div>