$(document).ready(function() {
    $('#table-tr thead tr').clone(true).appendTo( '#table-tr thead' );
    $('#table-tr thead tr:eq(1) th').each( function (i) {
        var title = $(this).text();
        $(this).html( '<input type="text" placeholder="Ara: '+title+'" />' );

        $( 'input', this ).on( 'keyup change', function () {
            if ( table.column(i).search() !== this.value ) {
                table
                .column(i)
                .search( this.value )
                .draw();
            }
        } );
    } );

    var table = $('#table-tr').DataTable( {
        orderCellsTop: true,
        fixedHeader: true
    } );
} );
Söyle bir js kodum var. Sistemde de tek bir js dosyası hazırladım ve ortak olan tüm js leri tek sayfada topluyorum fakat bazıları bazı sayfalarda olmayınca consele de hata kodu veriyor.
Özetle js de şunu diye biliyor muyum?
Sayfa hazırlandı ve sayfada 'table-tr' id li div var ise bu kodu çalıştır yoksa hiç çalıştırma.