Ignore span OR other html tag from TD in datatable

I am using the datatables I have a concern when I download the table it downloads the HTML tag in CSV format.
I want to ignore the span tag OR any HTML tag from TD in datatable.net
I am using this code as below.

<table>
    <thead>
        <tr>
            <td>SL</td>
            <td>VALUE</td>
        </tr>
    </thead>
    <tr role="row" class="odd">
        <td>1</td>
        <td>
            <a class="tools">0<span class="popup">--</span></a>
        </td>
    </tr>
</table>

var $_table = $("table").DataTable({
    responsive: true,
    scrollY: "300px",
    scrollX: true,
    scroller: true,

    colReorder: {
        fixedColumnsLeft: 1,
        fixedColumnsRight: 1,
    },

    bPaginate: false,
    lengthChange: false,
    searching: true,
    bInfo: false,
    classes: {
        sLength: "dataTables_length text-left w-auto",
    },

    buttons: {
        dom: {
            button: {
                className: "btn",
            },
            container: {
                className: "dt-buttons btn-group bgc-white-tp2 text-right w-auto",
            },
        },

        buttons: [
            {
                extend: "colvis",
                text: "<i class='fa fa-eye text-125 text-dark-m2'></i> <span class='d-none'>Show/hide columns</span>",
                className: "btn-light-default btn-bgc-white btn-h-outline-primary btn-a-outline-primary",
                columns: ":not(:first)",
            },

            {
                extend: "copy",
                text: "<i class='fa fa-copy text-125 text-purple'></i> <span class='d-none'>Copy to clipboard</span>",
                className: "btn-light-default btn-bgc-white btn-h-outline-primary btn-a-outline-primary",
            },

            {
                extend: "csv",
                text: "<i class='fa fa-download text-125 text-success-m1'></i> <span class='d-none'>Export to CSV</span>",
                className: "btn-light-default btn-bgc-white btn-h-outline-primary btn-a-outline-primary",
            },

            {
                extend: "print",
                text: "<i class='fa fa-print text-125 text-orange-d1'></i> <span class='d-none'>Print</span>",
                className: "btn-light-default btn-bgc-white  btn-h-outline-primary btn-a-outline-primary",
                autoPrint: false,
                message: "This print was produced using the Print button for DataTables",
            },
        ],
    },

    order: [],
});

I think this may be a JS question rather than a css one unless you simply want some CSS to remove a span in a td with css?

e.g.

td span{display:none}

I’m afraid I have no knowledge of datatables so will be of little help here sorry :frowning:

If this is a JS question then I can move the thread to JS for you?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.