jquery - How to call myScroll.scrollToElement when the page loads -


i using iscroll perform scrolls in webapp , happy it. in case need autoscroll specific li @ page load, having no luck it.

here trying do:

var myscroll;  function loaded () {     myscroll = new iscroll('#wrapper', { mousewheel: true, click: true }); }  document.addeventlistener('touchmove', function (e) { e.preventdefault(); }, false);  myscroll.scrolltoelement(document.queryselector('#scroller li:nth-child(50)'), null, null, true); 

if insert link this:

<a href="javascript:myscroll.scrolltoelement(document.queryselector('#scroller li:nth-child(50)'))"> 

everything works should... doing wrong?

i suggest using window.onload event exact same thing doing in function call should this:

window.onload = function() {    myscroll.scrolltoelement(document.queryselector('#scroller li:nth-child(50)'), null, null, true); } 

here more details onload event (you can attach html elements)


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -