我想根据选定的单选按钮显示一个隐藏的 div,例如:
<!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>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(".option_select").click(function() {
if ($('#extra_options').is(":hidden")) {
$('#extra_options').slideDown("slow");
}
});
});
</script>
</head>
<body>
<div id="extra_options" style="display:none;">
<input type="radio" name="ExtraOption" value="1" /> Extra option 1<br />
<input type="radio" name="ExtraOption" value="2" /> Extra option 2<br />
<input type="radio" name="ExtraOption" value="3" /> Extra option 3<br />
</div>
<form action="#" method="post">
<input type="radio" name="Option" class="option_select" value="1" /> Option 1<br />
<input type="radio" name="Option" class="option_select" value="2" /> Option 2<br />
<input type="radio" name="Option" class="option_select" value="3" /> Option 3<br />
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>
但我真的很想将#extra_options div 附加到选定的单选按钮(“选项 1、选项 2、选项 3 等),所以它看起来更像“这些额外选项与此选项一起使用 #”。我想我可以每个单选按钮都有一个#extra_optionsX div,但我认为有更好的方法。有什么想法吗?
TIA