There is HTML:

<div class="row1 td status_check status_waiting"> 

It is necessary to find if there is a class in the div, if it starts with "status", delete.

I even tried to find it, but it does not work:

 if (!$("div").attr('class').match(/status\-.+?\b/))alert('OK'); 

    1 answer 1

    @Maksim147, so in your regular expression - used as a separator, and in fact _ used.

    A similar question was on stackoverflow : " jQuery - Remove all classes with similar names "
    There was written a mini-plugin for jQuery, which is suitable for your case as well as possible:

     (function($) { $.fn.removeClassWild = function(mask) { return this.removeClass(function(index, cls) { var re = mask.replace(/\*/g, '\\S+'); return (cls.match(new RegExp('\\b' + re + '', 'g')) || []).join(' '); }); }; })(jQuery); 

    Using:

     $("div").removeClassWild("status_*"); 

    Result:

    <div class="row1 td">