Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery select input that is within a TD

Here is the HTML code that I copied/pasted using Firebug:

<div id="TBI">
<tr class="t-state-selected t-grid-edit-row">
    <td>8081</td>

    <td class="t-grid-edit-cell">
        <input id="ijn" class="text-box single-line valid" type="text" value=""  name="ijn"> 
    </td>

I'm able to access the 2nd cell of this table using the following:

$('#TBI tr.t-state-selected')[0].cells[1] 

and all works well.

But, how can I get a jquery reference to the input that is contained within the TD? Once I figure out how to get a selector for that text box, I can manipulate it as I wish.

Thanks ahead of time for help!

like image 209
carlg Avatar asked Mar 28 '26 19:03

carlg


2 Answers

Just try:

$("#TBI tr.t-state-selected input")

Or for the input inside the second td:

$("#TBI tr.t-state-selected:nth-child(1) input");

Demo: Fiddle

like image 158
mattytommo Avatar answered Mar 30 '26 10:03

mattytommo


$('#TBI tr.t-state-selected td input')
like image 40
jmar777 Avatar answered Mar 30 '26 09:03

jmar777



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!