How to select this specific td element and its text with Jquery

前端 未结 6 469
温柔的废话
温柔的废话 2020-12-19 18:39

I want to change the \"Yes! Pick me\" into \"Picked\" with Jquery in the following HTML structure, I used $(\'#myDiv>table>tr>td>table>tr\').eq(1).text(

6条回答
  •  抹茶落季
    2020-12-19 19:27

    $('#myDiv').find('table table td').eq(0).text(...);
    

    Start your selection at the #myDiv element ($('#myDiv')), then find all the TD element that are inside a table that is inside another table (.find('table table td')), then only alter the first one (.eq(0)).

    Documentation:

    • .find(): http://api.jquery.com/find
    • .eq(): http://api.jquery.com/eq

提交回复
热议问题