JQuery - Set TBODY

前端 未结 8 1366
梦如初夏
梦如初夏 2021-02-14 22:08

I have a table defined as follows:


    &         
8条回答
  •  情话喂你
    2021-02-14 22:52

    You would use:

    $("#myTable > tbody");
    

    which selects tbody elements that are the direct descendant of #myTable.

    Alternatively, you could use:

    $('tbody', '#myTable');
    

    which finds all tbody elements within the context of #myTable.

    In jQuery, there are often several ways to accomplish what you need.

    Another way, would be to do:

    $('#myTable').children('tbody');
    

    which is effectively the same as my first solution above.

    jQuery has great docs:

    Selectors: http://api.jquery.com/category/selectors/

    Traversing: http://api.jquery.com/category/traversing/

提交回复
热议问题
Date