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>
  <ul class="container"><li class="frame 1"><span>1</span></li><li class="frame 2"><span>2</span></li><li class="frame 3"><span>3</span></li><li class="frame 4"><span>4</span></li>
    </ul>
    <button class="increment">left</button>
    <button class="decrement">right</button>
</body>
</html>
 
class Rotator {
    constructor(list){
        this.list = list;
        
        this.increment = () => this.list.insertBefore(list.firstChild, list.lastChild);
        this.decrement = () => this.list.insertBefore(list.lastChild, list.firstChild);
    }
}
let rotator = new Rotator(document.querySelector('.container'));
document.querySelector('.increment').addEventListener('click', event => {
    rotator.increment();
});
document.querySelector('.decrement').addEventListener('click', event => {
    rotator.decrement();
});
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers