【发布时间】:2021-10-24 05:39:39
【问题描述】:
我正在 webflow 上构建一个站点,并尝试创建一个包含一些复选框来选择多个服务的表单。我正在尝试在选中复选框时添加样式(添加背景颜色并将标签和图标的颜色从黑色更改为白色,但是我实现的代码 jQuery 代码没有剪切它。我有多个框,因此添加唯一 ID 会使事情变得过于复杂。这是我目前所拥有的:
<script>
$('.checkbox-wrapper').on('click', function() {
if (!$(this).find('.checkbox-button').is(':checked') {
$(this).removeClass('active');
$(this).find('.checkbox-label').removeClass('active');
$(this).find('.checkbox-icon').removeClass('active');
}
else {
$(this).addClass('active');
$(this).find('.checkbox-label').addClass('active');
$(this).find('.checkbox-icon').addClass('active');
}
});
</script>
【问题讨论】: