I'm trying to highlight text in realtime using JQuery or Javascript. Current code doesn't want to search from .filters-no-actions
block.
How it should look like:
Note: I don't want to add new text to the .filters-no-actions
block, but only find text in this block using input value and highlight them.
CSS
.highlight_y {
background-color: yellow;
}
p, div {
display: inline-block;
}
HTML
<input id="ue__searchInput" placeholder="Search">
<div class="filters-no-actions">
<p>Example text to search</p>
<p>Lorem ipsum and...</p>
</div>
Script
$(document).ready(function(){
var search_input = $('#ue__searchInput');
$(search_input).change(function(){
var search_box = $('.filters-no-actions').text();
var search_box_val = search_box.val();
if (search_box_val == this.val()) {
search_box.append('<div class="highlight_y">' + search_box_val + '</div>');
}
});
});