I have some HTML elements which are hidden by default until user try to search for it. I am thinking to change the class of the element to show
when the DataTable search completed (if found).
Refer to the jQuery code below where I implement the search, what is the next step to show the parent or the container of it?
E.g. if the search key is c
or cc
or ccc
, how to show its parent (in this case is <li class="show">
)?
jQuery
$("#txtSearch").on('keyup keypress blur change', function(e) {
var val = $(this).val();
$('#mytable').DataTable().search(val).draw();
});
HTML
<li class="hide">aaa</li>
<li class="hide">bbb</li>
<li class="hide">ccc</li>