JSFiddle - React, Tailwind, and code Playground
HTML
<div>Some reallllly
realllyyy long text</div>
<div>Some other
div
</div>
JavaScript
$.expr[":"].mycontains = $.expr.createPseudo(function(arg) {
return function( elem ) {
return $(elem).text().replace(/(\n)+/g, " ").indexOf(arg) >= 0;
};
});
$(document).ready(function(){
$('div:contains("other")').css('color', 'green');
$('div:contains("Some other div")').css('border', '1px solid blue');
$('div:mycontains("Some reallllly realllyyy long text")').css('color', 'red');
$('div:mycontains("Some other div")').css('border', '1px dashed blue');
});