function checkradio(){
var item = $(":radio:checked");
var len=item.length;
if(len>0){
alert("yes--选中的值为:"+$(":radio:checked").val());
}
}
还有一个更经典的例子
/p>
"http://www.w3.org/TR/html4/loose.dtd">
New Web Projectwindow.οnlοad= function(){
var inpt= document.getElementById('myForm').getElementsByTagName('input'); //获取表单下所有的input元素
for(var i=0;i
if(inpt[i].type=='radio'){ //如果是单选按钮
if(inpt[i].defaultChecked) //页面载入时选中的值
document.getElementById('text1').value=inpt[i].nextSibling.nodeValue; //显示页面载入时选中的值
inpt[i].οnclick=function(){ // input的单击事件
if(this.checked)
document.getElementById('text2').value=this.nextSibling.nodeValue; //显示被选中的值
}
}
}
}
// 下面是用jquery实现
$(document).ready(function(){
$('input:radio').each(function(){
if(this.checked)
$('#text1').val($(this).val());
$(this).click(function(){
if(this.checked)
$('#text2').val($(this).val());
});
});
});
音乐
美术
电影
默认值:
选中值: