我正在使用一种样式表单,用于隐藏阅读单选按钮并用标签和图像替换它。现在,我希望在单击按钮后获取收音机的选中值 这是一个例子 http://jsfiddle.net/c2veopa3/1/
css代码
.example{
margin-bottom : 1.5em;
}
input[type=radio ]:not(old){
width : 28px;
margin : 0;
padding : 0;
opacity : 0;
}
input[type=radio ]:not(old) + label{
display : inline-block;
margin-left : -28px;
padding-left : 28px;
background : url('http://mawk3y.net/cards/checks.png') no-repeat 0 0;
line-height : 24px;
}
input[type=radio]:not(old):checked + label{
background-position : 0 -48px;
}
答案 0 :(得分:1)
只需这样:http://jsfiddle.net/c2veopa3/2/
$("input[type=radio]:checked").val();
答案 1 :(得分:1)
我改变你的css以匹配以下格式。您还应该在倒数第二个规则
中从属性选择器中删除空格input[type=radio]:not(.old):checked + label{ .. }
jquery的
$('[type=radio]:checked:not(.old)') // should select it, input not necessary
答案 2 :(得分:1)
不确定风格的相关性是什么,但这是直接使用你的小提琴:
$('#btn').click(function() {
console.log($('input[type=radio]:checked').val());
});