Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-1.9.1.min.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  <button id="btn">Execute</button>
  <!-- make sure type is not text/javascript, something gibberish that is not known to browser -->
  <script id="template" type="my-type">
    
     var buttons = [];
     buttons.push(1);
     buttons.push(2);
     return buttons;
     
  </script>
  <script>
    $('#btn').on('click',function(){
      
      var funBody = $('#template').html();
      alert(funBody);
      var fn = new Function(funBody);
      var b = fn();
      alert(b[1]);
      
    });
    
  </script>
</body>
</html>
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers