-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathchecked-polyfill.min.js
6 lines (5 loc) · 1.02 KB
/
checked-polyfill.min.js
1
2
3
4
5
6
/* Checked Polyfill 1.6
* Provides a .checked class that works like the :checked pseudo class on radio buttons and checkboxes but is available in older browsers such as IE7/8.
* https://github.com/rdebeasi/checked-polyfill
*/
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a(jQuery)}(function(a){a.fn.checkedPolyfill=function(b){function c(){var d,b=a('<style type="text/css"> #checkedPolyfill-test:checked { margin-left: 123456px; display: none; } </style>}'),c=a('<input type="checkbox" checked id="checkedPolyfill-test" />');return a("head").append(b),a("body").append(c),d="123456px"===c.css("margin-left"),b.remove(),c.remove(),d}function d(b){var c=a('label[for="'+b.attr("id")+'"]');return b.prop("checked")?(b.addClass("checked"),c.addClass("checked")):(b.removeClass("checked"),c.removeClass("checked")),b}return!c()&&this.each(function(){var b=a(this);"radio"===b.prop("type")?a('input[name="'+b.prop("name")+'"]').change(function(){d(b)}):"checkbox"===b.prop("type")&&b.change(function(){d(b)}),d(b)})}});