Skip to content

Instantly share code, notes, and snippets.

@robotmay
Last active December 11, 2015 22:08
Show Gist options
  • Save robotmay/4666976 to your computer and use it in GitHub Desktop.
Save robotmay/4666976 to your computer and use it in GitHub Desktop.
Rig checkboxes to look like links, because so many designers seem to want this lately. Adds a 'checked' class to the checkbox label and hides the input.
switchLabelClass = (el) ->
if $(el).attr("checked") == "checked"
$(el).parent().addClass("checked")
else
$(el).parent().removeClass("checked")
# Obviously change the form target here
checkbox_groups = $("form").find("input[type = 'checkbox']").each ->
$(this).hide()
switchLabelClass(this)
$(this).change =>
switchLabelClass(this)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment