html - How to autoscroll based on id or class value using javascript? -


the html code <div id="sim"></div> , related css code below

#sim{     width:800px;     height:300px;     border:solid 1px #2e2e2e;     color:#2e2e2e;     padding:5px; overflow:auto; border:9px outset #0ada0a; margin-top:1em; font-size:16pt; } 

its used reading simulation. if enter more 2000 words box, box changes scroll bar. when press button, reading highlighted on text.

but, border size width:800px; height:300px;, words overflow box, text has been hidden highlighting .

https://jsfiddle.net/8lwm6gh1/40/

how can see reading auto focus , auto scroll using js?

i might have misunderstood trying achieve, way comprehended wanted view scroll current word shown in div.

in order keep track of elements in view, used <span> each word, , attached class read on words have been read. way, can use jquery select next word having following selector:

var unread = $('span:not(.read):first'); 

i altered code wrote, , made work. never stop timeout, added cleartimeout()-function.

jsfiddle


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Website Login Issue developed in magento -

Can the constants be defined inside a model file of a framework in PHP? -