157
rated 0 times
[
160]
[
3]
/ answers: 1 / hits: 15483
/ 10 Years ago, thu, november 6, 2014, 12:00:00
This is the dummy code. My requirement is when I click on last li
element then one hidden div
inside it will be displayed.But I need to scroll
down to it to see it.
So when I click on li
with id=hello
then window should automatically scroll down to that div?
First preference using CSS then JS and no jQuery.
var ele=document.getElementById('hello');
ele.addEventListener(click, function (event) {
document.getElementById(hidden-div).style.display=block;
},false);
.fixed-height-div{
height:120px;
overflow-y:scroll;
}
.fixed-height-div > li{
background-color:lightblue;
list-style-type: none;
}
<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;>
This should be displayed after click<br><br>
And the scroll should come to this screen.
</div>
</li>
More From » html