0

I am highlighting my searched keyword - however it searches the HTML so if I have something like

<a href="espn.com?id=456">espn</a> 

and search on 456 - it finds it - I don't want that.

This is what I am using

function highlightOnly(text) {
    $('#' + view + ' td').each(function(i, e) {
        var $e = $(e);
        $e.html($(e).html().split(text).join('<span class="matching">' + text + '</span>'));
    })
}

$('.matching').replaceWith(function() {
    return this.innerText;
});

highlightOnly($('#txtSearch').val().toUpperCase());

You can see original fiddle here Search Keyword Highlighted

barbsan
  • 3,418
  • 11
  • 21
  • 28
Ronald
  • 557
  • 1
  • 9
  • 26

0 Answers0