if ($associatedElement.attr('type') === 'checkbox') {
e.preventDefault();
$customCheckbox = $(this).find('span.custom.checkbox');
-
//the checkbox might be outside after the label
if ($customCheckbox.length == 0) {
- $customCheckbox = $(this).next('span.custom.checkbox');
- }
- //the checkbox might be outside before the label
- if ($customCheckbox.length == 0) {
- $customCheckbox = $(this).prev('span.custom.checkbox');
+ $customCheckbox = $(this).siblings('span.custom.checkbox').first();
}
self.toggle_checkbox($customCheckbox);
} else if ($associatedElement.attr('type') === 'radio') {
$customRadio = $(this).find('span.custom.radio');
//the radio might be outside after the label
if ($customRadio.length == 0) {
- $customRadio = $(this).next('span.custom.radio');
- }
- //the radio might be outside before the label
- if ($customRadio.length == 0) {
- $customRadio = $(this).prev('span.custom.radio');
+ $customRadio = $(this).siblings('span.custom.radio').first();
}
self.toggle_radio($customRadio);
}