redcoder
redcoder

Reputation: 2333

search and remove span tag inside table

I have the following code and want use jquery to search and remove the entire <span>....</span> tag inside the table.

Can anyone help, please?

<table class="display groceryCrudTable dataTable" cellspacing="0" cellpadding="0">
    <tbody role="alert" aria-live="polite" aria-relevant="all">
    <tr>
        <td>24.80</td>
        <td><span id="func_date_temp" style="visibility:hidden;display:none;">2015-05-02</span>02/05/2015</td>
    </tr>
    </tbody>

</table>

UPDATE: Sorry, I want to remove the span tag when a button is clicked.My button code is as following.The id and class for all the tags are dynamic, possibly will change everytime page is loaded.Only the Export wording is fixed/permenant:

<div class="DTTT_container ui-buttonset ui-buttonset-multi">
<a id="ToolTables_528e10207a9eb_0" class="DTTT_button ui-button ui-state-default DTTT_button_xls">
<span>Export</span>
<div style="position: absolute; left: 0px; top: 0px; width: 49px; height: 26px; z-index: 99;">
</a>
</div>

Upvotes: 0

Views: 3760

Answers (4)

codingrose
codingrose

Reputation: 15709

remove() removes entire element.

Try:

$(".dataTable").find("#func_date_temp").remove();

Upvotes: 0

Murali Murugesan
Murali Murugesan

Reputation: 22619

try

$('table.display.groceryCrudTable').filter('span').remove();

Upvotes: 1

Try

$('#func_date_temp').remove();

As <span id="func_date_temp" has id


References

.remove()

# id-selector


if you want to remove all spans

$('table.display.groceryCrudTable span').remove();

Upvotes: 0

adeneo
adeneo

Reputation: 318302

It has an ID, which is unique and can be targeted, then just use remove() :

$('#func_date_temp').remove();

to remove the textnode following the span as well (if that's what you're trying to do) :

$('#func_date_temp').parent().empty();

EDIT:

to do it on button click:

$('#ToolTables_528e10207a9eb_0').on('click', function(e) {
    e.preventDefault();
    $('#func_date_temp').remove();
});

Upvotes: 2

Related Questions