将类添加到单选按钮 [英] Add class to radio button
本文介绍了将类添加到单选按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<input id="radio1" type="radio" name="rgroup" value="1" >
<label for="radio1"><span><span></span></span>1</label>
<input id="radio2" type="radio" name="rgroup" value="2" >
<label for="radio2"><span><span></span></span>1</label>
我有这样的东西,我想添加一个图像到使用javaScript检查的元素。
I have something like this and i want to add an image to the element which is checked using javaScript. How can i do it?
推荐答案
是否需要为要检查的收音机添加类?正如你可以用CSS简单做到的:
Is it important for you to add a class for the radio which is checked? As you can do that simply with CSS:
#radio1:checked + label {
color: #f00;
}
#radio1:checked + label:after {
content: url(IMAGE_URL_HERE);
}
演示2 (选择广告框时嵌入图片)
Demo 2 (With image embedded when you select the radio box)
演示3 (带有勾号图片)
Demo 3 (With tick image)
这篇关于将类添加到单选按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文