工作示例:https://codepen.io/stevland/pen/arOEEQ。
我正在使用jQuery根据打开/关闭哪个单选按钮来更改相应表的不透明度。
$('input:radio').click(function() {
$("input:radio").each(function() {
$(this).closest("table").toggleClass("highlight", $(this).is(":checked"));
});
});
除了一个警告之外,它运作良好:访问页面时,必须单击一个单选按钮以启动该功能。
我想根据页面上已选中的单选按钮来扩展代码,使其在页面加载后立即开始工作:
<input type="radio" checked />