简体   繁体   中英

DataTable.js - automatic init

I am trying to automatically init all data tables:

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

My table:

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

But I get the following error:

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

Anyone knows what I am missing?

Did you try with JQuery?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM