Format results from bootstrap datetimepicker v4

51 views Asked by At

I am using the following code:

$(document).ready(function () {   
    
            $('#myInput').datetimepicker({
                format: 'YYYY-MM-DD',
                
            });

            $('#myInput').on('dp.change', function (e) {
                var rex = new RegExp($(this).val(), "i");
            $("#actividades_curso tr").hide();
            $("#actividades_curso tr").filter(function () {
                return rex.test($(this).text());
            }).show();
            $(".noResults").hide();
            if ($("#actividades_curso tr:visible").length == 0) {
                $(".noResults").show();
            }
            });  
        });

The filtered results are ok but are shown without any css and the original table headers are gone. I'm new to javascript. Is there a way to format/apply css to the results?

1

There are 1 answers

0
Dupo On

Just for the purpose of this small function i got the results filtered by the '.filter()' method and keep everything with the style of the original table by just changing the 'area' of action of the filter method, in other words i changed the id ('#myTable') for the id of the body of my table, i have learnt to use fiddle js.

$('#ohbudy tr').filter( function(){ return rex.test($(this).text()); }).show();

https://jsfiddle.net/e6g1ucvn/