How to get all child inputs of a div element (jQuery)

前端 未结 6 1750
一生所求
一生所求 2020-12-12 11:52

HTML:

6条回答
  •  既然无缘
    2020-12-12 12:37

    You need

    var i = $("#panel input"); 
    

    or, depending on what exactly you want (see below)

    var i = $("#panel :input"); 
    

    the > will restrict to children, you want all descendants.

    EDIT: As Nick pointed out, there's a subtle difference between $("#panel input") and $("#panel :input).

    The first one will only retrieve elements of type input, that is , but not