gpt4 book ai didi

jquery - 跟踪选定的单选按钮并即时应用样式

转载 作者:太空宇宙 更新时间:2023-11-04 14:58:37 25 4
gpt4 key购买 nike

我需要跟踪选中了哪个单选按钮并为其添加/删除样式。

如何检测当前选中了哪个单选按钮。我只能跟踪用户打开页面时默认选中的内容。

有人可以帮助编写代码并分享链接以进一步阅读有关所用方法的信息。

非常感谢!

最佳答案

添加更改事件

var $radio = $('input[type="radio"]');

$radio.on('change', function() {
var $this = $(this);
this.checked ? $this.addClass('a') : $this.removeClass('a');
$radio.not(this).removeClass('a');
});

check Fiddle

关于jquery - 跟踪选定的单选按钮并即时应用样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16708916/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com