HTML
<form id='form-id'>
<input id='watch-me' name='test' type='radio' /> Show Div<br />
<input name='test' type='radio' /><br />
<input name='test' type='radio' />
</form>
<div id='show-me' style='display:none'>Hello</div>
Run Code Online (Sandbox Code Playgroud)
jQuery的
$('#form-id').change(function() {
if ($('#watch-me').attr('checked')) {
$('#show-me').show();
} else {
$('#show-me').hide();
}
});
Run Code Online (Sandbox Code Playgroud)
你可以在这里看到它:http://jsfiddle.net/wmKGd/
更新25.01.2013
从jQuery库1.8.x升级到1.9.x
请使用而不是
jQuery Library 1.8.x
jQuery('#some-id').attr('checked')
Run Code Online (Sandbox Code Playgroud)
jQuery Library 1.9.x.
jQuery('#some-id').prop('checked')
Run Code Online (Sandbox Code Playgroud)
你可以在这里看到更新的脚本:http://jsfiddle.net/9XXRY/