javascript toggle and anchor -


i starting in javascript, need help. have simple javascript toggles div on webpage. div working well, because in footer of page, opens , cannot see content. how make toggle scroll down entire div can seen?

i found similar examples other scripts, have not been able apply them here.

this javascript

function toggle() { var ele = document.getelementbyid("showindex"); var text = document.getelementbyid("displaytext"); if(ele.style.display == "inherit") {         ele.style.display = "none";         text.innerhtml = "show list"; } else {     ele.style.display = "inherit";     text.innerhtml = "show list"; } } 

this html

            <div id="indexslider">                 <a href="#showindex"><a id="displaytext" href="javascript:toggle();">show list</a></a>             </div>             <div id="showindex">                 content here several lines of links.             </div> 

try adding:

ele.scrollintoview(); 

after setting display "inherit".

it attempt scroll element top of page, end scrolling far can.


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -