0

Say I have a scroll-able div.

<div style="width:300px;height:150px;overflow:scroll;">
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    I WANT TO BE TOP OF THE SCROLLABLE DIV,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
</div>

The div will show starting with the first 'hi,' at the top. Now this is just an example, my scroll-able divs contain a lot more content than this example.

I would like to be able to somehow put focus on a certain area of the content that is displayed in the div. So with this example, the scrollbar would already be scrolled down a bit, where 'I WANT TO BE TOP OF THE SCROLLABLE DIV' shows at the top. How

Mr.Boon
  • 2,004
  • 7
  • 34
  • 47

1 Answers1

2

You can do it with pure html using a tag..

<a href="#scroll">click</a>
<div style="width:300px;height:150px;overflow:scroll;">
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    <span id="scroll">I WANT TO BE TOP OF THE SCROLLABLE DIV,</span><br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
    hi,<br />
</div>
Renzo Calla
  • 6,670
  • 2
  • 18
  • 35