0

I'm trying to run following script that I've founded here, written by dfsq in my project.

var $rows = $('#table tr');
$('#search').keyup(function() {

    var val = '^(?=.*\\b' + $.trim($(this).val()).split(/\s+/).join('\\b)(?=.*\\b') + ').*$',
        reg = RegExp(val, 'i'),
        text;

    $rows.show().filter(function() {
        text = $(this).text().replace(/\s+/g, ' ');
        return !reg.test(text);
    }).hide();
});

It looks simple however I have a certain problem. It searches not in all cells in rows (looks random) and sometimes not whole words (also can't see any dependency).

For example if I have "banana" in my cell and I try to type "ban" it doesn't show anything, but when I type "ana" it shows the row. Any idea what can go wrong?

(I cannot comment there)

[edit] I'm generating the document from php script. It may be relevant...

Community
  • 1
  • 1
Niko
  • 812
  • 9
  • 22

0 Answers0