jQuery datatables: test if datatables plugin is initialized

后端 未结 6 2377
猫巷女王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条回答
  •  旧时难觅i
    2021-02-13 01:04

    You can the fnIsDataTable function in jQuery datatable

    var ex = document.getElementById('example');
    if ( ! $.fn.DataTable.fnIsDataTable( ex ) ) {
      $(ex).dataTable();
    }
    

    You can find more information in api

提交回复
热议问题