Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get value of a specific row of a table using jquery

Tags:

jquery

How can I get a specific row value of a table(for exampe third row of fifth column) using jquery. I tried:

var t = document.getElementById('table');

    var val1 =$(t.rows[2].cells[4]).val();
    alert(val1);

But it is showing nothing

like image 800
sajju217 Avatar asked Jan 30 '26 08:01

sajju217


1 Answers

Try using :eq() selector at this context

.val() is only applicable for input elements, you should use .text() instead to retrieve its text content,

var val1 =$(t).find('tr:eq(2) td:eq(4)').text();
alert(val1);

Or do,

alert($('#table tr:eq(2) td:eq(4)').text());

DEMO

like image 78
Rajaprabhu Aravindasamy Avatar answered Feb 02 '26 01:02

Rajaprabhu Aravindasamy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!