作者:juventus蒂尼_578 | 来源:互联网 | 2023-06-08 08:50
So I have a series of radio buttons inside
elements. I'm trying to create a border on said
only when its child radio button is checked.
所以我在
元素中有一系列单选按钮。我尝试在said
元素中有一系列单选按钮。我尝试在说
的子单选按钮被选中时创建一个边框。
的子单选按钮被选中时创建一个边框。
I have a halfway solution here in jQuery:
我在jQuery中有一个折中方案:
$('input[type="radio"]').change(function() {
if($(this).is(':checked'))
{
$(this).parent().css('border', '1px solid black');
}
else
{
$(this).parent().css('border', 'none');
}
});
However, this only will add the style, but will not remove it when a different option in the radio buttons is selected. So, if you click all of the options, they all end up having the style applied.
但是,这只会添加样式,但是在选择单选按钮时不会删除它。所以,如果你点击所有选项,它们最终都会应用样式。
What can I do here?
我在这里能做什么?
1 个解决方案