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>
</head>
<body>
  <input type="checkbox" name="change" id="change">
  <label for="changem">Change Buttons</label><br><br>
  <div id="btngroup">
    <input id="OpenLayers_Control_LayerSwitcher_45_input_51" name="5000_fKr" type="checkbox" value="5000_fKr" checked="" class="olButton">
    
  <span><input type="checkbox" name="btngroup" id="btn-1"></span>
  
  <label for="btn-2">Button 2</label><br>
  <span><input type="radio" name="btngroup" id="btn-31"></span>
  <label for="btn-3">Button 3</label><br>
  </div>
</body>
</html>
 
$(document).ready(function() {
  $('#change').click(function() {
    if( $('#change:checked').length > 0 ) {
      var myType = "checkbox";
    }  else {
      var myType = "radio";
    }
    $("#btngroup span").each(function(i) {
      $(this).html('<input type="' + myType + '" name="btngroup" id="btn-' + i + '">');
    });
  });
});
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers