How to change value of a particular TD in a row with JQuery or Javascript? -


so if have table:

<table id="sometable">   <tr><td>key1</td><td>value1</td></tr>   <tr><td>key2</td><td>value2</td></tr>   <tr><td>key3</td><td>value3</td></tr> </table> 

is there way can "index of row" of value 2 , store value "key2" variable. using "index of row containing value2", change "first td"(or if there 3 td's, 3rd td) of row "changed key"?

something "index of tr" , specifying "index of td" change... not sure if possible jquery or javascript.

if know index of row , cell, this:

$(document).ready(function(){     $('#sometable tr:nth-child(2) td:nth-child(1)').html('foo'); }); 

you can pull current value of cell using same selector, .html() rather .html(content)

fiddle here


Comments