Check if element is before or after another element in jQuery

后端 未结 9 1580
花落未央
花落未央 2020-12-23 16:23

Let us suppose I have this markup

First

Hi

Hello

Second

9条回答
  •  萌比男神i
    2020-12-23 16:51

    I implemented a general isAfter function, which considers the depth and DOM tree and can correctly determine if a is after b even if they are in 2 different subtrees:

    I come first

    I come second

    you can find it in my GitHub Repository. Would appreciate your feedback on the code

提交回复
热议问题