How to Hide Tooltip if Value of the cell is Empty

How to Hide Tooltip if Value of the cell is Empty

Noodles12Noodles12 Posts: 113Questions: 41Answers: 2
edited March 2023 in Free community support

I am using hidden column to display the tooltip for datatables. It works fine but it shows tool tips on every cell of the table. Is there a way to hide the tooltip if the cell value is empty.
Please see my code here -https://live.datatables.net/jebatava/3/edit

From my example, the first row should not show tool tip on Test 6, Test 7 etc columns, second row should not show tooltip on Test4, Test 5 columns. Any help/advice appreciated. Thanks.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,327Questions: 26Answers: 4,949
    Answer ✓

    Looks like these cells have a single space created with  . You will need to adjust your if statement to account for the whitespace, something like this if (cell.innerText.trim() !== '') {. Updated example:
    https://live.datatables.net/jebatava/4/edit

    Kevin

  • Noodles12Noodles12 Posts: 113Questions: 41Answers: 2

    Thankyou. That did it!

  • Noodles12Noodles12 Posts: 113Questions: 41Answers: 2
    edited March 2023

    I just tested the tool tip using screen reader for 508 complaince and it seems the screenreader does not read the tool tip. Any idea why? Please let me know if you want me to open a seperate question for this. Thanks.

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    You'd probably need to refer to the support / documentation for the screen reader you are using. I'm not sure what the rules they apply are for what happens with a title attribute for a td.

    I doubt that is DataTables specific - presumably it happens with even just a plain HTML table?

    Allan

Sign In or Register to comment.