If element contains any of these words then wrap that word in span

by hannes

HTML

<h1>This title contains the word Balloon</h1>
<h2>This title contains the Veerpalu Villa word Oranges</h2>
<h1>This title doesn't contain either of those terms</h1>

CSS

.wrap {color : red}

JavaScript

var words = ["veerpalu villa","balloon"];

$('h1,h2').html(function(_,html) {
    var reg = new RegExp('('+words.join('|')+')','gi');
    return html.replace(reg, '<span class="wrap">$1</span>', html)
});