SoptikHa SoptikHa - 21 days ago 5
Javascript Question

How to change element in another element

I have a page which has several

<tr>
elements, which contains three things:


  • <td>
    with number and dot behind it (like this:
    <td>19.</td>
    )

  • <td>
    with description

  • <td>
    with checkbox



<table>
<!-- Some other <tr>s there... -->
<tr id="somethingGeneratedWhichIDontKnow">
<td id="aduju1j">13.</td>
<td id="ajdi1">lorem ipsum dolor sit amet consectetur adipiscing elit</td>
<td id="3j21">
<input type="checkbox" id="3125ac_a">
</td>
</tr>
<!-- Some other <tr>s there... -->
</table>


I need to find
<tr>
element which has 1st
<td>
with some number and change the checkbox there.

So my question is: How can I find the right checkbox? ID of elements is generated by web, so I can't select it by ID. I accept both javascript and jQuery answers.

I'm new to JS and jQuery so thanks you for all your help :-)

Joe Joe
Answer
var checkbox = $('td:contains("13.")').eq(0).parent().find(":checkbox")