jQuery datatables: test if datatables plugin is initialized

后端 未结 6 2378
猫巷女王i
猫巷女王i 2021-02-13 00:34

I want to check if a table element with say, id=\"datatable\" is datatables-initialized. Something like this:

if ($(\'#datatable\').dataTable().initialized) {
           


        
6条回答
  •  时光取名叫无心
    2021-02-13 01:05

    Datatable has a method to check if an element has been initialized as a datatable or not - $.fn.DataTable.fnIsDataTable

    tableElement = document.getElementById('your table ID');
    $.fn.DataTable.fnIsDataTable(tableElement); // returns true or false
    

提交回复
热议问题