扫码关注官方订阅号
我想通过选择 radio 按钮更换对应的p border颜色为红色。 有没有高手指点一下?
HTML
2件999 2件999
2件999
CSS
.discount{ border: 1px solid #cccccc; padding:2px; width:100%; }
如截图
小伙看你根骨奇佳,潜力无限,来学PHP伐。
https://jsfiddle.net/rtf6w78b/
需要 jQuery,es6 语法
$(":radio").on("change", e => { const $p = $(e.target).closest(".discount"); console.log($p); $(".discount").removeClass("checked"); $p.addClass("checked"); });
css中:.checktopup{border: 1px solid #f00;}js中,记得引入jquery$("input").on("click", function() {
$(".discount").addClass("checktopup").siblings().removeClass("checktopup"); window.checktopup=this; checked = true
})
当选项的checked值为true的时候,添加class
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
https://jsfiddle.net/rtf6w78b/
css中:
.checktopup{
border: 1px solid #f00;
}
js中,记得引入jquery
$("input").on("click", function() {
})
当选项的checked值为true的时候,添加class