DataTable.js - 自动初始化

DataTable.js - automatic init

我正在尝试自动初始化所​​有数据 tables:

var dataTables = document.getElements('table.datatable');
for(var i= 0; < dataTables.length; i++) {
  dataTables[i].DataTable();
}

我的table:

<table cellspacing="0" class="table datatable table-striped table-bordered no-footer" id="articlestable">

但我收到以下错误:

TypeError: dataTables[i].dataTable is not a function

有人知道我错过了什么吗?

你试过 JQuery 了吗?

 $(document).ready(function() {
    $('table.datatable').dataTable();       
 });