SoptikHa SoptikHa - 1 year ago 92
Javascript Question

How to change element in another element

I have a page which has several

elements, which contains three things:

  • <td>
    with number and dot behind it (like this:

  • <td>
    with description

  • <td>
    with checkbox

<!-- 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">
<!-- Some other <tr>s there... -->

I need to find
element which has 1st
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 Source
var checkbox = $('td:contains("13.")').eq(0).parent().find(":checkbox")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download