jquery - table header is getting hidden during autocomplete -


as user types in input searching table , displaying results accordingly .

but issue facing table header being hidden after search .

this code

$(document).ready(function() {         $('#searchinputtext').keyup(function()         {                 var tr = $('#videosfromtagstable tbody tr'); //use tr not td                 if ($(this).val().length >= 2)                 {                         var inputdata = $.trim($("#searchinputtext").val());                         $('#errmsgnovideos').hide();                         var noelemvideo = true;                         var val = $.trim(this.value).tolowercase();                         el = tr.filter(function()                         {                                 return $(this).find('td:eq(0)').text().tolowercase().indexof(val) >= 0;                         }); // <==== closest("tr") removed                         if (el.length >= 1)                         {                                 noelemvideo = false;                         }                         //now fadein/out every row not every cell                         tr.not(el).fadeout();                         el.fadein();                         if (noelemvideo)                                 if (inputdata !== '')                                 {                                         $('#errmsgnovideos').html('no results matched').show();                                 }                                 else                                 {                                         $('#errmsgnovideos').hide();                                 }                 }                 else                 {                         tr.fadein(); //show if length not match required number of characters                         $('#errmsgnovideos').hide();                 }         }) }); 

http://jsfiddle.net/cod7ceho/307/

could please tell me how resolve issue .

use <thead>

<input type="text" id="searchinputtext" class="form-control" placeholder="search">    <span id="errmsgnovideos"></span> <table class="mytable1 table table-bordered table-hover" id="videosfromtagstable"> <thead>     <tr class="existingvideos">          <th width="20%">name</th>          <th width="35%">file</th>          <th width="30%">course</th>          <th width="15%">seepz</th>       </tr> </thead>    <tbody class="connectedsortable ui-sortable">        <tr video-id="48" title="" class="newvideos exercises-add-table-content">          <td>dsada</td>          <td><a href="xxx" target="_blank">dftyr.mp4</a></td>          <td>             <span class="btn btn-sm btn-success btn-circle">five</span>          </td>          <td><i class="fa fa-check"></i></td>       </tr>       <tr video-id="49" title="" class="newvideos exercises-add-table-content">          <td>fds</td>          <td><a href="xxx" target="_blank">dftyr.mp4</a></td>          <td>             <span class="btn btn-sm btn-success btn-circle">five</span>          </td>          <td><i class="fa fa-check"></i></td>       </tr>    </tbody> </table> 

demo:http://jsfiddle.net/cod7ceho/308/

or if type "i can't modify html"

$('#videosfromtagstable tbody tr:not(:first)'); 

http://jsfiddle.net/cod7ceho/312/


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -