Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the value of a textbox inside a <td> using the id of <tr> in jquery

Tags:

jquery

i have a table like this

<table>
<tr id ='1tr'>
<td><input type='textbox' value='1'></td>
 <td><input type='textbox' value='2'></td>
 </tr> 
 <tr id ='2tr'>
  <td><input type='textbox' value='3'></td>
  <td><input type='textbox' value='4'></td>
  </tr>
 </table>

how i can get the value of text box in second td that is in tr with id 2tr

like image 327
Warrior Avatar asked Dec 31 '25 00:12

Warrior


2 Answers

Try this code:

$('#1 input').val();​

New code after your edit in your answer

$('#2tr td:eq(1) input').val();

is what you want?

like image 175
Alessandro Minoccheri Avatar answered Jan 01 '26 14:01

Alessandro Minoccheri


There is no textbox in tr with id '1', so I guess you wnat this one out of tr with id '2'...

You can write:

$('#2 td input').val()

But it is not recommended to use number as ID in an HTML-DOM!

like image 33
iappwebdev Avatar answered Jan 01 '26 14:01

iappwebdev