JSFiddle - React, Tailwind, and code Playground

HTML

<div id="wordpresspost" class="bodyclass post-id-193 wordpresswrap bg1">test</div>

CSS

.bg1{
    background: red; 
}
.bg2{
    background: green;
}

.bg5 { height:200px; }

JavaScript

var classList =$('#wordpresspost').attr('class').split(/\s+/);
$.each( classList, function(index, item){
    var wordpresspost = $('#wordpresspost');
    if (item === 'bg1') {
       wordpresspost.removeClass('bg1').addClass('bg2');
    }
     if (item === 'bodyclass') {
       wordpresspost.addClass('bg5');
    }
});