时间:2021-07-01 10:21:17 帮助过:5人阅读
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>ready(fn)事件</title>
<script type="text/javascript" src="jquery-2.0.3.js"></script>
<style type="text/css">
body{
background-color:#CCCCFF;
font-size:24px;
font-weight:bold;
text-align:center;
}
.body_div{
padding:20px 20px 20px 20px;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
$("input[type='radio']").click(function(){
var se = $("input[name='sex'][type='radio']:checked").val();
if(se == "男"){
alert("男性");
}
if(se == "女"){
alert("女性");
}
});
});
</script>
</head>
<body>
<div class="body_div">
<input type="radio" id="male" name="sex" value="男"/>男
<input type="radio" id="female" name="sex" value="女"/>女
</div>
</body>
</html>
4、结果如下:
(1)选择“男”时
(2)选择“女”时