Created
December 5, 2014 23:07
-
-
Save zackn9ne/ff3cf00281aef1c237c2 to your computer and use it in GitHub Desktop.
a script to toggle checkboxes and radial buttons where ie8 complaince is heeded
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var customUI = { | |
| toggleChecked: function (labelSelector) { | |
| $(labelSelector).each(function () { | |
| var label = $(this); | |
| var input = label.find("input:first"); | |
| if (input.length > 0) { | |
| if (input.get(0).checked) { | |
| label.addClass("checked"); | |
| } else { | |
| label.removeClass("checked"); | |
| } | |
| } | |
| }); | |
| }, | |
| initCheckboxes: function () { | |
| $("label.checkbox").each(function () { | |
| var label = $(this); | |
| label.click(function () { | |
| customUI.toggleChecked(this); | |
| }); | |
| label.find("input").each(function () { | |
| $(this).change(function () { | |
| customUI.toggleChecked($(this).parents("label:first")); | |
| }); | |
| }); | |
| customUI.toggleChecked(this); | |
| }); | |
| }, | |
| initRadioButtons: function () { | |
| $(".radioList").each(function () { | |
| $(this).find("input").each(function () { | |
| $(this).change(function () { | |
| customUI.toggleChecked($(this).parents(".radioList:first").find("label")); | |
| }); | |
| }); | |
| }); | |
| }, | |
| init: function () { | |
| customUI.initCheckboxes(); | |
| customUI.initRadioButtons(); | |
| } | |
| }; | |
| $(document).ready(customUI.init); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment