jQuery: Find previous element with class

前端 未结 4 410
生来不讨喜
生来不讨喜 2020-12-17 10:22

I have a really simple problem.

How can I find the first previous element of another element? I tried the code below without success.

HTML:

&         


        
4条回答
  •  旧巷少年郎
    2020-12-17 11:03

    if you want to target closest children of top parent you can do so as something define below.

    lets assume you have an HTML like

    similarly if you want to target grandparent next parent containers children just change .prev() to .next()

    hope i made it simple to define :)

提交回复
热议问题