0

In a javascript web app I am displaying a rather long table, filled with data coming from firebase, with code like the following.

̧  const dbReference = firebase.database().ref('MyCollection').child('CHD')

  dbReference.on('value', function(list) {
    list.forEach(function(item) {
      itemR = document.createElement('tr'),
      itemD = document.createElement('td'),
      .... useful code laying out the item inside the table ....
    }
  }

It works as expected and I end up with my list of items in a table. But I need something more.

How can I make the window scroll automatically to a given position. For instance, to have the 157th item in the list to show at the top of the window. I have already searched the net and found some scroll functions that I tried, but with no success.

Michel
  • 10,303
  • 17
  • 82
  • 179

1 Answers1

0

you could add an id attribute to all the items and then have an anchor tag point to it

<a href="#157">SCROLL</a>
...
<td id="157"></td>
Nils Schwebel
  • 641
  • 4
  • 14