I have the following code. I tried running inside the element with the class ACTIVE, a code that checked to see if it had the VIOLET word within the element with the class TITLE . But instead of executing only on the element with the class ACTIVE, it ran on all that were with the word VIOLET:
var Violet = /Violet/gi;
$('.title').append($('div').hasClass("active")).contents().each(function() {
if (this.nodeType === 3 && this.nodeValue.match(Violet)) {
alert('teste')
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><ulclass="owl-1">
<div class="owl-item active">
<li>
<div class="title">Violet</div>
</li>
</div>
<div class="owl-item">
<li>
<div class="title">Violet</div>
</li>
</div>
<div class="owl-item">
<li>
<div class="title">Evergarden</div>
</li>
</div>
</ul>