You could try something like this:
$(".element small").text(function(index, text) {
return text.replace('Draft', 'Draft Demonatisation ');
}).toggleClass(function(){
var $class = "";
$class += ($(this).text().indexOf('Draft') > -1 ? " textbot":"")
$class += ($(this).text().indexOf('Demonatisation') > -1 ? " textbite":"")
return $class;
});
Demo
$(".element small").text(function(index, text) {
return text.replace('Draft', 'Draft Demonatisation ');
}).toggleClass(function(){
var $class = "";
$class += ($(this).text().indexOf('Draft') > -1 ? " textbot":"")
$class += ($(this).text().indexOf('Demonatisation') > -1 ? " textbite":"")
return $class;
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="element">
<small>Draft</small>
</div>
CLICK HERE to find out more related problems solutions.