Changing div content based on scroll position

前端 未结 1 894
伪装坚强ぢ
伪装坚强ぢ 2020-12-11 19:21

I am hoping for some help using this code from another Stack Exchange post. Below is the javascript:

$(window).on(\"scroll resize\", function(){
    var pos=         


        
1条回答
  •  星月不相逢
    2020-12-11 20:08

    Add an hidden element inside each section containing the description, for i.e. :

    ....

    then in javascript get the description of the relevant section like this:

    if(pos.top >= $(this).offset().top && pos.top <= $(this).next().offset().top)
            {
                $('#date').html($(this).find('.description').text());
                return;
            }
    

    Jsfiddle

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