javascript - How to scroll to particular element using CSS/JS -
javascript - How to scroll to particular element using CSS/JS -
this dummy code. requirement when click on lastly li
element 1 hidden div
within displayed.but need scroll
downwards see it. when click on li
id=hello
window should automatically scroll downwards div?
first preference using css js , no jquery.
class="snippet-code-js lang-js prettyprint-override">var ele=document.getelementbyid('hello'); ele.addeventlistener("click", function (event) { document.getelementbyid("hidden-div").style.display="block"; },false);
class="snippet-code-css lang-css prettyprint-override">.fixed-height-div{ height:120px; overflow-y:scroll; } .fixed-height-div > li{ background-color:lightblue; list-style-type: none; }
class="snippet-code-html lang-html prettyprint-override"><div class="fixed-height-div"> <li>a</li> <li>b</li> <li>c</li> <li>d</li> <li>e</li> <li>f</li> <li>g</li> <li id="hello">h <div id="hidden-div" style="display:none;"> should displayed after click<br><br> , scroll should come screen. </div> </li>
just after show/expand hidden div, phone call scrollintoview
function of li
element requires no jquery.
function showit(el_id) { var el = document.getelementbyid(el_id); el.scrollintoview(true); }
for more refer https://developer.mozilla.org/en-us/docs/web/api/element.scrollintoview
javascript html css css3 scroll
Comments
Post a Comment