jquery - How to select the nth child of each subsequent sibling -


i have html looks this:

<tbody>     <tr id="upload_row_0">     <tr id="upload_row_1">     <tr id="upload_row_2">         <td>             <select name="task_exec_platform">         </td>         <td>             <input type="file" name="task_exec_config_2">         </td>         <td>             <input type="file" name="task_exec_2">         </td>         <td>             <a onclick="deletetaskexecrow("#upload_row_2")">         </td>     </tr> </tbody> 

each row expands , includes similar <td> elements, showing snippet brevity's sake. id "upload_row_0" stored in variable, obj.

i want select 2nd child of each subsequent sibling row. in other words, want change name "task_exec_config_2" rows 1 , 2. able capture subsequent rows using nextall(), unsure how select 2nd child each of elements. current attempt is

$(obj).nextall().$(":nth-child(2)").children().attr("name", "new_name"); 

but know isn't right.

thanks!

i think want move nth-child next all

$(obj).nextall(':nth-child(2)').attr("name", "new_name"); 

update
going off you're original one, see youre trying do.

$(obj).nextall().$(":nth-child(2)").attr("name", "new_name"); 

you need replace $.(...) after nextall find, , select child input

$(obj).nextall().find(":nth-child(2) input").attr("name", "new_name"); 

made fiddle visually see you're selecting:
https://jsfiddle.net/9oqj3z78/2/


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -