Which is more efficient: .parent().parent().parent() ~or~ parents(“.foo”) ~or~ closest(“.foo”)

前端 未结 7 1782
-上瘾入骨i
-上瘾入骨i 2020-12-15 03:06

I have an A tag which triggers the animation of it\'s great-great-great-grandparent. All of the following will work, but which is most efficient, and why?

$         


        
相关标签:
7条回答
  • 2020-12-15 04:10

    It is a very good thing that you did performance measurements. That's exactly what should be done in such scenarios. If all appear to run smoothly in practice and you are satisfied with the performance pick the most readable one (second and third look ok).

    0 讨论(0)
提交回复
热议问题