Reputation: 241
I'm able to get the row by using td text using "contains", but it fails if it has the text in td > span text.. Here is my scenario
<table id="tblAllMessages">
<tr><td>100</td><td><span>hi</span></td></tr>
<tr><td>200</td><td><span>100</span></td></tr>
</table>
if I use
$('#tblAllMessages td:contains('100')').parent("tr")
it will give me two rows.. But, I need only first row. It should not check 100 in second row, because its under span of a td..
Do I need to add anything else?
Upvotes: 0
Views: 61
Reputation: 28513
Try using :first
like below :
$('#tblAllMessages tr td:nth-child(6):contains("100"):not(:has(span)):first').closest('tr')
Working JSfiddle
For More information on :first
please see :First API Doc
Upvotes: 0
Reputation: 148654
Try this :
(prettified version)
$('#tblAllMessages td')
.filter(function ()
{
return $("<div/>").text($(this).html()).html()=='100'
})
.closest("tr").css('background-color','red')
http://jsbin.com/wizacahi/2/edit
The trick I used is not to find any html entities inside it. ( but PURE text)
Upvotes: 1
Reputation: 1631
try this,this will work
$(document).ready(function(){
var $pressTitle =$('#tblAllMessages').find('td:first');
var pressTitle=$pressTitle.next().text();
alert(pressTitle);
});
</script>
Upvotes: 0