$(document).ready(function(){
$("#tb tr").each(function(){
//在jquery中用each的时候,经常用到$(this) ,这时如果想查找子项可以通过$(this).find("element")来查找。
$(this).find("input[type=button]:first").click(function(){
alert($(this).attr("id"));
});
});
$(".rSex").each(function(){
$(this).change(function(){
//获取radio选中的值
alert($(".rSex:input[name=rSex]:checked").val());
});
});
$("#txtSelect").blur(function(){
if($.trim($(this).val())!="")
{
if($.trim($(this).val())=='男')
{
//1、设置radio的选中项
$("input[name=rSex]").get(0).checked=true;
//2、设置radio的选中项
//$("input[name=rSex][value='男']").attr("checked",true);
/*3、网上有一种方法是
$("input[name=rSex]").attr("checked","男")
即:attr中是属性checked 和value
我测试是错误的。
*/
}
if($.trim($(this).val())=='女')
{
$("input[name=rSex]").get(1).checked=true;
}
}
});
});
获得Radio的值
$("input[name='evaluate']:checked").val()
Radio事件
$("input[type='radio'][name='rage']").click(function(){Js.showselectinfo();})
$("input[type='radio'][name='rage']").click(function(){$("input[name='evaluate']:checked").attr("id")})
评论