0

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?

  • Try with `get()`: `$('#view').get().scrollWidth` – Baro May 12 '21 at 10:57
  • Now it says "Unexpected token ':'" Incidentally I just put your suggested code in a line above what I have: I don't really know how to use JavaScript, so I don't know if that is what you meant. – Patrick Lauser May 13 '21 at 10:36

0 Answers0