jquery find to get the first element

前端 未结 6 1454
忘掉有多难
忘掉有多难 2020-12-29 19:11

I am writing $(this).closest(\'.comment\').find(\'form\').toggle(\'slow\'); and the problem is each of the forms in the child is being toggled. I would like on

6条回答
  •  猫巷女王i
    2020-12-29 19:34

    You can use either

    $(this).closest('.comment').find('form').eq(0).toggle('slow');
    

    or

    $(this).closest('.comment').find('form:first').toggle('slow');
    

提交回复
热议问题