Created
February 11, 2014 16:31
-
-
Save barmatz/8938365 to your computer and use it in GitHub Desktop.
A jQuery dependant snippet that adds support to styled checkbox/radio elements in IE8
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
| function initIE8Checkbox() { | |
| jQuery('body').find('input[type="checkbox"] + label, input[type="radio"] + label'). | |
| on('click', function (event) { | |
| var element = document.getElementById(event.target.getAttribute('for')); | |
| jQuery('body').find('input[name="' + element.name + '"]').removeClass('checked'); | |
| jQuery(element).toggleClass('checked'); | |
| }).each(function (index, element) { | |
| element = document.getElementById(element.getAttribute('for')); | |
| if (element.checked) { | |
| jQuery(element).addClass('checked'); | |
| } | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment