jquery - 加载时的jQuery检测选择了哪个单选按钮
问题描述
工作示例: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 />
解决方案
推荐阅读
- python - Keras:结合数据生成器来处理图像+文本
- reactjs - 连接路由器 A
可能只有一个子元素,但它有一个子元素 - java - Java Web Start 应用程序读取本地文件
- django - 在 Django 中,中间模型是否需要与目标模型属于同一个文件?
- c - 检查平衡括号的C程序
- javascript - Jquery 包含特殊字符和小写
- python - PyInstaller 应用程序的设置图标
- amazon-web-services - AWS Glue - 读取 Amazon S3 存储桶中的所有对象
- actionscript - Flash Actionscript 2.0 localToGlobal 坐标问题
- ios - iOS:了解导航推送后何时加载两个视图控制器的最佳实践