查找文本并将其删除 jquery
Find text and remove it jquery
可能的重复项:
使用 jQuery 查找文本字符串?
你如何找到一个文本字符串并使用jquery隐藏它。
<div class="report-box">
<div class="title">test</div>
<table>
<tbody>
<tr align="center" class="CellLabel">
<td colspan="2">Day at a Glance</td>
</tr>
<tr class="CellLabel">
<td>New Clients</td>
<td>00000</td>
</tr>
<tr class="CellLabel">
< td>Money Received</td>
<td>$ 0000,000.0000</td>
</tr>
<tr class="CellLabel">
<td>Overdue Invoices</td>
<td>0000000</td>
</tr>
<tr class="CellLabel">
<td>Services</td>
<td>000000</td>
</tr>
<tr align="right" class="CellLabel">
<td colspan="2"></td>
</tr>
</tbody>
</table>
</div>
我将如何删除
<tr class="CellLabel">
<td>Money Received</td>
<td>$ 0000,000.0000</td>
</tr>
从代码中使用 jQuery。
首先,你的html有点混乱,缺少一些标签。但是你去吧。;)
1:
预览 - http://jsfiddle.net/Xpc63/1/
$('.CellLabel').removeByContent('Money');
有关完整的 JS 代码,请参阅预览。
阿拉伯数字:
预览 - http://jsfiddle.net/ahzPs/1/
$('.CellLabel').contains('Money').remove();
有关完整的 JS 代码,请参阅预览。
3:
预览 - http://jsfiddle.net/mWtzw/
$('.CellLabel').filter(function() {
return $(this).html().indexOf('Money') != -1;
}).remove();
您可以使用包含选择器方法:
$('td:contains("$ 0000,000.0000")').parent().hide(); //to hide
$('td:contains("$ 0000,000.0000")').parent().remove(); //to remove
或者,如果您只想删除或隐藏包含文本的 td:
$('td:contains("$ 0000,000.0000")').hide(); //to hide
$('td:contains("$ 0000,000.0000")').remove(); //to remove
$('.cellLabel').find('td:contains("money")').remove();
// just want to remove
$('.cellLabel').find('td:contains("Money Received")').parent.remove();
或
// if just want to hide
$('.cellLabel').find('td:contains("Money Received")').parent.hide();
相关文章:
- 如何在不删除类似侦听器的情况下从父对象中删除jQuery事件侦听器
- 如何比较两个字符串并删除jquery中的元素
- 从此代码中删除 Jquery
- 删除jQuery添加的按钮
- 如何删除jQuery.haverage()方法中的延迟
- 如何删除jQuery组中其他成员的后代元素
- 删除jQuery中的事件不起作用
- 添加和删除jquery-li元素
- 如何删除jquery可拖动项的子项
- 如何编辑和删除jQuery数据表的每一行
- 使用滑动存储cookie以删除jquery mobile
- 如何从 HTML 元素中停止或删除 jQuery 函数
- 如何删除 jquery 可折叠数据角色=“可折叠”
- 删除 Jquery/Javascript 对象中的字符
- 删除 jQuery 上的内容
- 从数据表中删除 jquery MVC5
- 查找文本并将其删除 jquery
- 动态预置和删除 JQuery/JavaScript
- 更改父选择框时如何删除 Jquery 中的旧选项
- 删除 jQuery 中的数组元素