Change CSS for specific Table

Change CSS for specific Table

ybathiaybathia Posts: 5Questions: 2Answers: 0

I have multiple datatables on a single page and I would want to change the css of the search input box of only one of my tables. All the examples suggest using $('.dataTables_filter input').css('color', 'white'); but by using dataTables_filter input, it changes the css of all my search input boxes.How can I change the css of just one table?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,552Questions: 1Answers: 10,477 Site admin
    Answer ✓

    Assign an id to the table (if you haven't already), then DataTables will use that id for the wrapper element - giving the wrapper (i.e. the div that contains all of the DataTables "stuff") the id {tableId}_wrapper.

    For example, if your table is id="myTable" the wrapper is generated as id="myTable_wrapper".

    Then you can use simple selectors to target a specific table: $('#myTable_wrapper .dataTables_filter input').

    Allan

  • ybathiaybathia Posts: 5Questions: 2Answers: 0
    edited March 2015

    Thanks @allan

This discussion has been closed.