Reputation: 1
I have the following markup which have SPAN >> Table >> TR >> TD
:-
now i want to specify either using css or jquery to remove the TR which have a TD that contain the word "Question" inside <nobr>
tag. so can anyone adivce how i can do so ? thanks
Upvotes: 4
Views: 2035
Reputation: 1448
You can do it with jQuery as shown below:
$(document).ready(function(){
$('td').each(function(){
if($(this).find('nobr').text() === 'Question') {
$(this).closest('tr').remove();
}
});
});
Upvotes: 1
Reputation: 3200
It would have been helpful if you could provide HTML. I would have created fiddle but You can try below solution
Iterate tr in table and find the tr having
$("table.ms-formtable > tbody > tr").each(function(){
var text = $(this).find("td:first").find("nobr").text();
if(text === 'Question') {
$(this).remove();
}
});
Upvotes: 0
Reputation: 67207
Try to use :has()
selector along with :contains()
selecor to achieve what you want,
$("tr:has(td nobr:contains('Question'))").remove();
Upvotes: 1
Reputation: 78545
You can use filter to compare the exact text of the <nobr>
element, then remove the closest <tr>
$("span table tr td nobr").filter(function() {
return $(this).text() === "Question";
}).closest("tr").remove();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span>
<table>
<tr>
<td>
<h3>
<nobr>Question</nobr>
</h3>
</td>
</tr>
<tr>
<td>
Untouched
</td>
</tr>
</table>
</span>
Upvotes: 3