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>
  <h1>selector test</h1>
  
  <ul>
    <li>apple</li>
    <li>orange</li>
    <li>banana</li>
    <li>grape</li>
    <li>strawberry</li>
  </ul>
  
  <button onclick=addFruitElement() id="btn_add">ADD</button>
  <button onclick=removeFruitElement() id="btn_remove">REMOVE</button>
</body>
</html>
 
const list = document.querySelector("ul");
function addFruitElement() {
  const sp1 = document.createElement("li");
  const sp1_content = document.createTextNode("mango");
  sp1.appendChild(sp1_content);
  list.appendChild(sp1);
}
function removeFruitElement() {
  list.removeChild(list.lastElementChild);
}
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers