jquery当radio值发生变化时触发行为

JQueryradiochecked选中事件2010-08-0911:57<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<headrunat="server">

<title>test</title>

<scriptsrc="jquery-1.4.2.min.js"type="text/javascript"></script>

<scripttype="text/javascript">

$(document).ready(function(){

$(".radioItem").change(

function(){

var$selectedvalue=$("input[name='rl$tt']:checked").val();

alert($selectedvalue);

if($selectedvalue==1){

window.location="http://www.g.cn";

}

else{

window.location="http://www.baidu.com";

}

});});

</script>

</head>

<body>

<tableid="rl">

<tr>

<td><label>谷歌</label>

<inputid="rl_1"class="radioItem"checked="checked"name="rl$tt"type="radio"value="1"/>

<label>百度</label>

<inputid="rl_2"class="radioItem"name="rl$tt"type="radio"value="2"/></td>

</tr>

</table>

</body>

</html>

相关推荐