<script type="text/javascript">
function radio_form(){
var selectvalue = $('input[name=choice]:checked', '#radio_form').val();
if(selectvalue == "V1"){
alert('Value 1');
return true;
}else if(selectvalue == "V2"){
alert('Value 2');
return true;
}else if(selectvalue == 'V3'){
alert('Value 3');
return true;
}else if(selectvalue == 'V4'){
alert('Value 4');
return true;
}
return false;
};
</script>
<form id="radio_form">
<input type="radio" onclick="radio_form()" name="choice" value="V1">
<input type="radio" onclick="radio_form()" name="choice" value="V2">
<input type="radio" onclick="radio_form()" name="choice" value="V3">
<input type="radio" onclick="radio_form()" name="choice" value="V4">
</form>
我试图在选择无线电值时显示警报......但是这种方法似乎不起作用。选择单选按钮值时显示提醒
我做错了什么?
如果您正在使用jquery你需要的是($(本).VAL()),并点击功能 - 演示 - http://jsfiddle.net/z66fbof2/ – Tasos
@TasosAnastasiou我能重定向到一个网址例如? – Borsn
从无线电选择我假设?是的,将该值更改为“http://somesite.com”,然后看到下面的答案 – Tasos