Set initial scroll position failed

29 views Asked by At

I'm using Twine, and I'm using this code to try to set the initial scroll position to the middle:

var scrollToMiddle = ($('#view')[0].scrollWidth - $('#view').width()) / 2; $('#view').scrollLeft(scrollToMiddle);

But it gives me the error: "Cannot read property 'scrollWidth' of undefined"

Why is this?

0

There are 0 answers