How can I tell if a page has jumped to the anchor (#) in javascript?

前端 未结 3 1272
抹茶落季
抹茶落季 2021-02-08 11:29

I have some javascript that can appear on many different pages. Sometimes those pages have been accessed via a URL containing an anchor reference (#comment-100, for instance).

3条回答
  •  轮回少年
    2021-02-08 11:53

    To detect when the element appears on the screen, use the appear plugin:

    $('#comment-1').appear(function() {
      $(this).text('scrolled');
    });
    

提交回复
热议问题