On 2024-10-18 08:35 +05:30, Raghavendra Nyshadham wrote:
AFAIK, exporting tables with specific id attributes is not straightforward, but you can abuse the class attribute by putting the id in it.
I think I was wrong about that:it looks like you can inject a specific id into a table element with attr_html; I must've misunderstood something I'd read. So the following should work too, and does not abuse the class attribute. Cheers, Raghavendra. #+title: Org Tables to DataTables #+html_doctype: html5 #+html_head: <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script> #+html_head: <script src="https://cdn.datatables.net/2.1.8/js/dataTables.min.js"></script> #+html_head: <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/2.1.8/css/dataTables.dataTables.min.css" /> #+html_head: <script>$(document).ready(function () {$('table#example').DataTable();});</script> #+html_head: <script>$(document).ready(function () {$('table#another-example').DataTable({lengthMenu: [3, {label: 'All', value: -1}]});});</script> This is an example table. #+attr_html: :id example :class cell-border hover compact :width 100% | Name | Position | Office | |-------------+------------------+---------------| | Tiger Nixon | System Architect | Edinburgh | | Ashton Cox | Technical Author | San Francisco | ------------------------------------------------------------ This is another example table. #+attr_html: :id another-example :class display | Author | Title | Shelf | |-------------------+-------------------------+-------| | Capote, Truman | In cold blood | D3B | | Chandler, Raymond | The high window | D3B | | Dai, Mamang | The legends of Pensam | D3B | | Desai, Kiran | The inheritance of loss | D3B | | Farrell, J. G. | The hill station | C1B |