Reputation: 2333
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
Reputation: 15709
remove()
removes entire element.
Try:
$(".dataTable").find("#func_date_temp").remove();
Upvotes: 0
Reputation: 22619
try
$('table.display.groceryCrudTable').filter('span').remove();
Upvotes: 1
Reputation: 57095
Try
$('#func_date_temp').remove();
As <span id="func_date_temp"
has id
spans
$('table.display.groceryCrudTable span').remove();
Upvotes: 0
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