Live search through table rows

前端 未结 15 1866
失恋的感觉
失恋的感觉 2020-11-29 00:52

I want to do a live search through the table rows, using jQuery, the \"live\" word is the key, because I want to type the keywords in the text input, on the same site and I\

15条回答
  •  甜味超标
    2020-11-29 01:21

    Here's how I live search a html table:

    ...

    function filterTo(input, table) {
    var tr = document.getElementById(table).getElementsByTagName('tr');
    for (var i = 1; i < tr.length; i++) {
        var td = tr[i].getElementsByTagName('td');
        var hide = true;
        for (var j=0; j -1) { hide=false; break } 
        }
        tr[i].style.display = hide ? 'none' : '';
    } }
    

提交回复
热议问题