jquery find to get the first element

前端 未结 6 1421
忘掉有多难
忘掉有多难 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条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-29 19:43

    I use

    $([selector]).slice(0, 1)
    

    because it's the most explicit way to select a slice of a query and because it can be easily modified to match not the first element but the next, etc.

提交回复
热议问题