Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
<!--[if IE]>
  <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
  article, aside, figure, footer, header, hgroup, 
  menu, nav, section { display: block; }
</style>
</head>
<body>
  <p id="container">Hello World</p>
</body>
</html>
 
var data = {'name':'form','elements':[{'name':'bt1','type':'button','value':'hello','order':'1'},{'name':'img1', 'type':'image','src':'http://placekitten.com/200/300','order':'2'}]};
var container = $("#container"), 
    i = 0;
container.html("");
while ( current = data.elements[i++] ) {
  switch ( current.type ) {
    case "button":
    case "image" :
      $("<input>", current).appendTo(container);
      break;
  }
}
container.on("click", "input", function(){
  alert( this.value || this.src );
});
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers