检查特定输入后如何更改标签?(how to make a tag change properties after a specific input is checked?)

编程入门 行业动态 更新时间:2024-10-26 23:38:03
检查特定输入后如何更改标签?(how to make a tag change properties after a specific input is checked?)

我正在为学校项目创建一个测验网站。 每当选择正确答案(input type=radio)我希望与其相邻的线变为green ,当选择了错误答案时,我希望线变为red 。

有没有办法只使用css而不是JavaScript 。

I am creating a quiz website for a school project. Whenever a correct answer is selected (input type=radio) then I want the line adjacent to it to become green and when an incorrect answer is selected I want the line to become red.

Is there any way to do this using css only and not JavaScript.

最满意答案

在输入中有一些属性表明它是正确的选项,然后使用[attribute="value"]在CSS中监听它,然后使用某种运算符(如+ )选择下一个标记(p等)

JSfiddle演示

Have some attribute in your input indicating that it's the right option and then listen for it in CSS using the [attribute="value"] then select the next tag (p etc.) with some kind of operator (like +)

JSfiddle demo

更多推荐

本文发布于:2023-08-05 02:49:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1426163.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何更改   标签   tag   change   checked

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!