基本上,我正在关注我的这篇文章,如果我必须显示单选按钮以及其中的 和 显示 div,则以下解决方案可以正常工作:
$(".tier1-options :radio").on("change", function (e) {
//remove shown class from all tier2 options and clear values from all form elements inside it
$('.tier2-options')
.removeClass('shown')
.find('input, select').val('')
//show the related tier2 options
$(this)
.parents('.tier1-options')
.find('.tier2-options')
.addClass('shown')
});
.tier2-options {
display: none;
margin-left: 1rem;
padding: 1rem;
background-color: #EEE;
}
.shown{
display: block;
}
Select one of the checkboxes:
但是当我尝试添加多个单选按钮时,此代码不适用于移动内容选项。基本上,当我点击Tier I Move或Tier II Move
subtier2-options不会显示
$(".tier1-options :radio").on("change", function (e) {
//remove shown class from all tier2 options and clear values from all form elements inside it
$('.tier2-options')
.removeClass('shown')
.find('input, select').val('')
//show the related tier2 options
$(this)
.parents('.tier1-options')
.find('.tier2-options')
.addClass('shown')
});
$(".subtier1-options :radio").on("change", function (e) {
//remove shown class from all tier2 options and clear values from all form elements inside it
$('.subtier2-options')
.removeClass('shown')
.find('input, select').val('')
//show the related tier2 options
$(this)
.parents('.subtier1-options')
.find('.subtier2-options')
.addClass('shown')
});
.tier2-options {
display: none;
margin-left: 1rem;
padding: 1rem;
background-color: #EEE;
}
.shown{
display: block;
}
.subtier2-options {
display: none;
margin-left: 1rem;
padding: 1rem;
background-color: #EEE;
}
Select one of the checkboxes:
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号