DOM Enlightenment Book
HTML
<script src="https://getfirebug.com/firebug-lite-debug.js"></script>
<div>
<content>
<p>1</p>
<p>2</p>
<p>3</p>
<p>4</p>
<p>5</p>
<p>6</p>
<p>7</p>
<p>8</p>
<p>9</p>
<p>10</p>
</content>
</div>
<h4 style="border-top:1px solid #ADADAD;padding-top:20px;margin-top:20px;"><strong>← Code Example from <a href="http://www.domenlightenment.com/" target="_blank">DOM Enlightenment Book</a> by <a href="http://www.codylindley.com" target="_blank">Cody Lindley</a></strong></h4>
<p style="background-color:#fff">JavaScript code is executed on page load. Click the "Run" button in the top bar to re-run the JavaScript code. All <code>console.log()'s</code> are logged to the <a href="http://getfirebug.com/firebuglite" target="_blank">Firebug Lite</a> console below ↓.</p>
CSS
div{height:30px;width:30px; overflow:auto;}
p{background-color:red;}
JavaScript
//select <p>5</p> and scroll that element into view, I pass children '4' because its a zero index array-like structure
document.querySelector('content').children[8].scrollIntoView(true);