如何组合两个JavaScript代码块

如何组合两个JavaScript代码块,javascript,datatables,Javascript,Datatables,我是javascript新手,我试图组合2个javascript块,但我正在崩溃 第一块 <script> $(document).ready(function() { // Setup - add a text input to each footer cell $('table.table tfoot th').each( function () { var title = $(this).text(); $(this).html(

我是javascript新手,我试图组合2个javascript块,但我正在崩溃

第一块

<script>
$(document).ready(function() {
    // Setup - add a text input to each footer cell
    $('table.table tfoot th').each( function () {
        var title = $(this).text();
        $(this).html( '<input type="text" placeholder="'+title+' ARA" />' );
    } );

    // DataTable
    var table = $('table.table').DataTable();

    // Apply the search
    table.columns().every( function () {
        var that = this;

        $( 'input', this.footer() ).on( 'keyup change', function () {
            if ( that.search() !== this.value ) {
                that
                    .search( this.value )
                    .draw();
            }
        } );
    } );
} );
</script>

我想在第一个javascript中添加“oLanguage”和“order”行。我该怎么办?

只需将粘贴数组从
数据表复制到第一部分:

$(document).ready(function() {
    // Setup - add a text input to each footer cell
    $('table.table tfoot th').each(function () {
        $(this).html('<input type="text" placeholder="'+$(this).text()+' ARA" />');
    });

    // DataTable
    var table = $('table.table').DataTable({
        order: [
          [0, "desc"]
        ],
        paging: true,
        oLanguage: {
          sUrl: "js/dil/LANGUAGE.json",
        }
    });

    // Apply the search
    table.columns().every(function () {
        var that = this;

        $('input', this.footer()).on('keyup change', function () {
            if (that.search() !== this.value ) {
                that
                    .search( this.value )
                    .draw();
            }
        });
    });
});
$(文档).ready(函数(){
//设置-向每个页脚单元格添加文本输入
$('table.table tfoot th')。每个(函数(){
$(this.html(“”);
});
//数据表
var table=$('table.table').DataTable({
订单:[
[0,“描述”]
],
是的,
语言:{
sUrl:“js/dil/LANGUAGE.json”,
}
});
//应用搜索
table.columns().every(函数(){
var=这个;
$('input',this.footer()).on('keyup change',function(){
如果(that.search()!==this.value){
那个
.search(this.value)
.draw();
}
});
});
});

注意数据表过去在注释中有它的变量,后来被移动到camlCase,因此新API很可能无法识别你的
语言

+$(此)。text()+不显示seacrh结果?其他人正在工作
$(document).ready(function() {
    // Setup - add a text input to each footer cell
    $('table.table tfoot th').each(function () {
        $(this).html('<input type="text" placeholder="'+$(this).text()+' ARA" />');
    });

    // DataTable
    var table = $('table.table').DataTable({
        order: [
          [0, "desc"]
        ],
        paging: true,
        oLanguage: {
          sUrl: "js/dil/LANGUAGE.json",
        }
    });

    // Apply the search
    table.columns().every(function () {
        var that = this;

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