Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am generating some div id's dynamically using the function

C#
generate: function(){


    $("#contenttext br ~ br").each(function(index,element) {

        $(this).after("<div id=\"bookmark-" + index + "\"></span>");

        var key= $('div[id^="bookmark-" ]');

        $('div:visible', key)


    });



    },




i want to save the visible div id when the page is scroll down ,and  
jump back or scroll back to the saved div id when the page is loaded, 


i am acheiving this by passing static div id (for example  #bookmark-65) in the below code , but i want to save the div id according to the scroll position and pass it back when page is reload ,same as saving cookie or local storage...but by using dynamically generated div id's

scroll:function()
{


    var container = $('div'),
        scrollTo = $('#bookmark-65');

    container.animate({
            scrollTop: scrollTo.offset().top - container.offset().top + container.scrollTop()

    });


any one help me..
Posted
Updated 17-Apr-15 15:57pm
v2

1 solution

SQL
If you want to save the id and use it in same page then you can do it by assigning it to a variable such as divid="bookmark-" + index ;
And use it in anywhere in the same page
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900