Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
<button class="updateList">Update List</button> 
<div class="app"></div> 
<ul class="list">
    <li>hello</li>
    <li>World</li>
    <li>Whats up</li>
</ul>
</body>
</html>
 
var list = document.querySelector('.list');
var button = document.querySelector('.updateList');
function updateList(){
    var number = Math.round(Math.random()*100);
    var li = document.createElement('li');
    li.textContent = number;
    list.appendChild(li);
    var lastLi = document.querySelector('.list li:last-child');
    lastLi.scrollIntoView();    
}
button.addEventListener('click', updateList);
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
azs06pro
0viewers