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 onclick="useIt()">Use me</button>
<div id="container"></div>
<script>
  function useIt() {
    const content = document.querySelector('#counter-template').content;
    // Update something in the template DOM.
    let span = content.querySelector('span');
    span.textContent = parseInt(span.textContent) + 1;
    document.querySelector('#container').appendChild(
        document.importNode(content, true));
  }
</script>
<template id="counter-template">
  <div>Template used: <span>0</span></div>
</template>
</body>
</html>
Output

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

Dismiss x