, JavaScript.
:
<input type="checkbox" id="jim" />
<label for="jim"></label>
, :
input + label { }
? : , :
input + label { background-position: 0 0; }
input:checked + label { background-position: 100% 0; }
, - for = "jim" . , , .
input { display: none; }
, , , , . , : , , , .
, : (IE8 ), 'checked'. - :
jQuery(document).bind('change', function(e){
var elem = jQuery(e.target);
// If this is not a checkox, do nothing.
if (elem.attr('type') !== 'checkbox') { return; }
// Add or remove checked class based on current state.
if (elem.attr('checked')) { elem.removeClass('checked'); }
else { elem.addClass('checked'); }
});
... .