效果如下:
//復選框也是如此
代碼如下:
<!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=utf-8" />
<title>無標題文檔</title>
<style type="text/css">
p{border:1px solid red;width:100px;height:100px;}
</style>
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(function(){
$(".rad").click(function(){
if($(this).attr("value")=="1")
$("#show").show();
else
$("#show").hide();
});
});
</script>
</head>
<body>
<input type="radio" name="commend" value="1" checked="checked" class="rad" />YES
<input type="radio" name="commend" value="0" class="rad"/>NO
<p id="show">要顯示的DIV內容</p>
</body>
</html>