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.4.0/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>
  <form> 
<label for="same">all the same as first?</label> 
<input id="same" name="same" type="checkbox" /> 
<input type="text" id="foo[1]" name="foo[1]" value="" /> 
<input type="text" id="foo[2]" name="foo[2]" value="" /> 
<input type="text" id="foo[3]" name="foo[3]" value="" /> 
<input type="text" id="foo[4]" name="foo[4]" value="" /> 
<input type="text" id="foo[5]" name="foo[5]" value="" /> 
    <br />
    <input type="text" id="TEST" name="TEST" value="" /> 
</form> 
</body>
</html>
 
    $("input#same").click(function(){
      var checkBox = $(this);
       if (checkBox.attr("checked")){
         $("form input[name^=foo]").val($("input[name^=foo]:first").val());
        }else{
          $("form input[name^=foo]:not(:first)").val("");
        }
    }); 
Output 300px

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

Dismiss x
public
Bin info
anonymouspro
0viewers