Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-git2.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  <p>
    <label>Click text or radio <input type="radio" id="my_radio_1" /></label></p>
  <p><button>Click button <input type="radio" /></button></p>
</body>
</html>
 
button input[type=radio] {
  display:none;
}
button:after{
  content: "☐";
}
button.checked:after{
  content: "☑";
}
 
$('#my_radio_1').click(function() {
    $(this).toggleAttr('checked');
    $(this).blur();
});
$('button').click(function() {
  $(this)
      .toggleClass('checked')
  .find('input').toggleAttr('checked');
});
/**
 * toggleAttr Plugin
 */
jQuery.fn.toggleAttr = function(attr) {
    return this.each(function() {
        var $this = $(this);
        if($this.attr(attr)){
           $this.removeAttr(attr);
        } else {
          $this.attr(attr, attr);          
        } 
    });
};
Output 300px

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

Dismiss x
public
Bin info
kadimipro
0viewers