Skip to content

Instantly share code, notes, and snippets.

@notch8-old
Created December 7, 2011 21:00
Show Gist options
  • Select an option

  • Save notch8-old/1444628 to your computer and use it in GitHub Desktop.

Select an option

Save notch8-old/1444628 to your computer and use it in GitHub Desktop.
// Prime function
$('.iswitch label input:checked').each(function(){
$(this).parents("label").addClass("on");
})
$(".iswitch label span input:[type=checkbox][checked=false]").each(function(){
$(this).parents("label").addClass("off");
})
// Change function
$('.iswitch label').click(function() {
if($(this).find('input').attr('checked'))
{
$(this).find('input').prop("checked", false);
$(this).removeClass("on");
$(this).addClass("off");
}
else
{
$(this).find('input').prop("checked", true);
$(this).removeClass("off");
$(this).addClass("on");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment