[英]prettyCheckboxes make parent div clickable?
I am using prettyCheckboxes and I want to change it so that the div wrapper can also be clicked as well as the radio button. 我正在使用prettyCheckboxes,我想对其进行更改,以便可以单击div包装器以及单选按钮。 The currently JS for the radio button/label is 当前单选按钮/标签的JS是
$label = $('label[for="'+$(this).attr('id')+'"]');
// Add the checkbox holder to the label
$label.prepend("<span class='holderWrap'><span class='holder'></span></span>");
// If the checkbox is checked, display it as checked
if($(this).is(':checked')) { $label.addClass('checked'); };
// Assign the class on the label
$label.addClass(settings.className).addClass($(this).attr('type')).addClass(settings.display);
// Assign the dimensions to the checkbox display
$label.find('span.holderWrap').width(settings.checkboxWidth).height(settings.checkboxHeight);
$label.find('span.holder').width(settings.checkboxWidth);
// Hide the checkbox
$(this).addClass('hiddenCheckbox');
// Associate the click event
$label.bind('click',function(){
$('input#' + $(this).attr('for')).triggerHandler('click');
if($('input#' + $(this).attr('for')).is(':checkbox')){
$(this).toggleClass('checked');
$('input#' + $(this).attr('for')).checked = true;
$(this).find('span.holder').css('top',0);
}else{
$toCheck = $('input#' + $(this).attr('for'));
// Uncheck all radio
$('input[name="'+$toCheck.attr('name')+'"]').each(function(){
$('label[for="' + $(this).attr('id')+'"]').removeClass('checked');
});
$(this).addClass('checked');
$toCheck.checked = true;
};
});
and I want to make it so the $(this).parent() also calls the click function. 我想做到这一点,所以$(this).parent()也调用click函数。
Any ideas how I could do this? 有什么想法可以做到吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.